|Is there a PHP equivalent to Java URL filters/interceptors?||#1|
One of the things I like about Java servlets is the use of unobtrusive filters and interceptors. Basically you could use these things to enforce security, put extra information on the
, do monitoring or whatever.
Is there some equivalent in PHP?
From what I've seen so far it seems that you tend to include a certain file in all your pages that will do things like start the session, enforce security, etc. Not as elegant. Is that the only solution?
posted date: 2008-12-27 17:06:00
|Re: Is there a PHP equivalent to Java URL filters/interceptors?||#3|
There isn't any servlet API equivalent provided with PHP, so the quick answer is you need to implement the logic yourself.You have a lot of elbowroom on how you can accomplish this. The practice is to create a certain flow of control within your application by starting off with one file through which all requests are initially processed that will initialize some values, such as constants, file paths, etc, after which you start parsing the request and generate the requested content.Obviously, it's quite quick to set up some main file and to parse the request. In the past we had the "one .php file to rule them all" practice taken to the max. You'd usually have a single file that would include the header, footer and based on some incoming GET or POST params you'd also include some other pages that would generate or display the content. You can easily understand how messy things could get!My suggestion, before you go off and try to develop something yourself, is to try some of the existing frameworks that are already out there and start getting productive asap. I'll presume that PHP is not your primary expertise and that you're shopping for a framework that you can get up and running fast and quickly grasp it's complete scope. Two of them, CodeIgniter and CakePHP, are as frameworks to PHP as WordPress is to blogging - functional, simple and effective.If frameworks don't follow suit with your likings, you should definitely read The no-framework PHP MVC framework.
posted date: 2008-12-27 18:01:00
|Re: Is there a PHP equivalent to Java URL filters/interceptors?||#4|
Nope, maybe a close call though.There is a config directive to instruct php to include automagically a file in yours
That can be useful for writing something similar. You should peruse filter library embedded since php 5.2 (the last version available).http://it.php.net/manual/en/filter.configuration.php. I've not used it already but it seems interesting.By the way the framework hint is a valuable one.Though I don't like them (often I've to fight the framework and not the problem I had assigned).
posted date: 2008-12-27 18:44:00
|Re: Is there a PHP equivalent to Java URL filters/interceptors?||#5|
the filter library is just there for parsing/filtering/sanitizing of input data.
posted date: 2014-01-23 06:34:00
|select page: « 1 »|