What causes the “Twig_Environment not found” error? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forum-6.html) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forum-17.html) +--- Thread: What causes the “Twig_Environment not found” error? (/thread-78015.html) What causes the “Twig_Environment not found” error? - Ajax30 - 11-19-2020 I am working on a online newspaper/blogging application with CodeIgniter 3.1.8 and Bootstrap 4. I have decided to add themes to it. The application is not HMVC, only MVC. I thought it was a good idea to use the Twig template engine to the theme(s). For this purpose, I use CodeIgniter Simple and Secure Twig. In the third_party directory I have added Twig (version 1.x) itself. In application\config\autoload.php, I have loaded Twig: PHP Code:$autoload['libraries'] = array('database', 'form_validation', 'session', 'user_agent', 'twig');  The problem In the browser, I get the error: Code:Message: Class 'Twig_Environment' not found. Filename: path\to\root\application\libraries\Twig.php What am I doing wrong? RE: What causes the “Twig_Environment not found” error? - InsiteFX - 11-19-2020 The library should be installed in the ThridParty folder. Then in you controller. PHP Code:// If you don't use Composer, uncomment below/*require_once APPPATH . 'third_party/Twig-1.xx.x/lib/Twig/Autoloader.php';Twig_Autoloader::register();*/  Are you doing that? Twig for Developers RE: What causes the “Twig_Environment not found” error? - Ajax30 - 11-20-2020 (11-19-2020, 05:05 PM)InsiteFX Wrote: The library should be installed in the ThridParty folder. Then in you controller. PHP Code:// If you don't use Composer, uncomment below/*require_once APPPATH . 'third_party/Twig-1.xx.x/lib/Twig/Autoloader.php';Twig_Autoloader::register();*/  Are you doing that? Twig for Developers Yes, I already did all that. RE: What causes the “Twig_Environment not found” error? - superior - 11-21-2020 Isn't third_party libraries loaded through the$autoload['packages'] array? Autoloading libraries only looks for the /application/libraries/* directory, you use the /application/third_party/* directory for this.. Edit: My mistake, reading to fast on this topic.   You use the correct folder according to the documentation Do you encounter the same issue when you install the required environment through composer? Based on the error you give i think the Twig_Environment isn't loaded correctly. RE: What causes the “Twig_Environment not found” error? - Ajax30 - 11-21-2020 (11-21-2020, 02:13 PM)superior Wrote: Isn't third_party libraries loaded through the \$autoload['packages'] array? Autoloading libraries only looks for the /application/libraries/* directory, you use the /application/third_party/* directory for this.. Edit: My mistake, reading to fast on this topic.   You use the correct folder according to the documentation Do you encounter the same issue when you install the required environment through composer? Based on the error you give i think the Twig_Environment isn't loaded correctly. I have not tried with Composer and I would rather not. I want the deployment process to be very simple. Have a look at the GitHub repo.  Thanks! RE: What causes the “Twig_Environment not found” error? - InsiteFX - 11-21-2020 PHP Code:@trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED);  RE: What causes the “Twig_Environment not found” error? - Ajax30 - 11-22-2020 (11-21-2020, 09:11 PM)InsiteFX Wrote: PHP Code:@trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED);  I have switched to Twig-1.2.0 and now I get a "Class 'Twig_Extension_Debug' not found" message. Filename: path[font=Times New Roman]\to[font=Times New Roman]\app[/font]\application\libraries\Twig.php[/font] Line Number: 131 RE: What causes the “Twig_Environment not found” error? - superior - 11-23-2020 (11-22-2020, 02:57 AM)Ajax30 Wrote: (11-21-2020, 09:11 PM)InsiteFX Wrote: PHP Code:@trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED);  I have switched to Twig-1.2.0 and now I get a "Class 'Twig_Extension_Debug' not found" message. Filename: path[font=Times New Roman]\to[font=Times New Roman]\app[/font]\application\libraries\Twig.php[/font] Line Number: 131 Why would you downgrade? What do you have against composer, it's easier to maintain the packages and versions this way. You are missing the required classes as the error is telling to you: 'Class {classname} not found'