Twig with php __autoload() method? -


I have a problem with PHP (5.3.13) and twig I use twang as a standalone in a project I do not, with Symphony 2. I try to use the PHP __autoload () method to load my own classes, but the class is not loaded due to the triggered: Here is my project:

  myproject / | _ Classes / | | _ Myclass1.class.php | | _ Myclass2.class.php | _ Lib / | | _twig / | | _ Lib / | | _chig / | | _ Autoloader.php | _ Index.php | _ Autoload.php  

index.php code:

  need_once ("lib / twig / lib / twig / autoloader.php"); Twig_Autoloader :: Register (); $ Loader = new \ Twig_Loader_Filesystem ("templates"); $ Tpl = new \ Twig_Environment ($ loader, array ("cache" = & gt; wrong)); {$ OTemplate = $ tpl- & gt; Try the Load Template ($ sId. "Html"); } Hold (Twig_Error_Loader $ E) {$ oTemplate = $ tpl- & gt; LoadTemplate ("404.html"); } Need_once ("autoload.php"); $ Object = new myclass1 ();  

autoload.php code:

  function __autoload ($ sClass) {include_once "classes /".$ sClass." Class.php "; }  

and the error is:

  Fatal error: Class 'myclass1' was not found C: \ Program Files \ wamp \ www \ myproject \ index Php ' 

How to solve it? I have read that I should use the namespace, but I do not know how.

you __autolog () and (used by reggae) or Then by using the spl_autoload_register () to skip the PHP code to re-enable your functionality in the __autoload () implementation, or follow it later.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -