问题
I work on ready made framework (legacy framework).Its almost like any other MVC framwork you get in market, except that its not having single entry point.
So in every Controller file I have to include configs & Model classes.
Currently I manage with __autoload() , but still one include is left on every page.
If I add .htaccess for single entry point then I have to do lots of changes in my code.Because every controller file is different physical file.Its not even near to object oriented structure and for views smarty is used.
Is there any solution including .htaccess rules , instead of php.ini? It will be easier to maintain.
Please suggest best solutions for my dificulty.
回答1:
The best suggestion I could give you is by using auto prepend files. Before any script runs, a piece of code is prepended to it.
In Apache you can set this per directory using the php_value auto_prepend_file xxx.php directive.
回答2:
You could route all traffic to one PHP script, usually index.php like so:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
Then index.php would handle all necessary library files and handle the routing for the controllers.
来源:https://stackoverflow.com/questions/12178941/need-single-entry-point-like-solution