0

I know this is a bit strange but I'm toying with a concept and I'm not sure the best method to execute it.

In PHP, you have the ability to make methods and properties public or private. Within our project, I want to force our php controllers to behave the same way a front end app would in terms of access, which means no business logic and limited access. Of course I could manually enforce this, but I like the idea of being able to use object privacy to enforce it. Of course, I could make methods private or protected (which may are) but then no other classes at all can interact with these methods/properties.

What I'd almost like is another type of privacy where only SPECIFIED FILES/FOLDERS ETC. can interact with methods/properties

In concept, what I'd essentially like to see is something like:

  • private
  • protected
  • limited - Only certain folders/files whatever can interact with
  • public

(actually, in my exact situation, I'm using Laravel so I would be using this within models and it would be basically commands and other models that are allowed to access)

I know that this is tricky and I haven't seen it used before, but I think there might be some creative solution to make it work. I know I can't actually define a new access type but maybe with some trickery I could make my models have something similar?

Has anyone ever heard of anything similar? Do any other programming languages have anything like this?

tlenss
  • 2,609
  • 2
  • 22
  • 26
Sabrina Leggett
  • 9,079
  • 7
  • 47
  • 50
  • 1
    Sounds like you need some form of ACL – tlenss Mar 30 '15 at 15:02
  • 1
    Write custom `__get` and `__set` functions with checks on these specific files/folders somewhere. Make all "limited" properties private! – sjagr Mar 30 '15 at 15:02
  • I've normally seen ACL being used for user based permissions and I've seen it done at routes level? Will look into it more for internal control... – Sabrina Leggett Mar 30 '15 at 15:31

0 Answers0