What causes the “Twig_Environment not found” error? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: What causes the “Twig_Environment not found” error? (/showthread.php?tid=78015) |
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. 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 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. 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.. 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: I have switched to Twig-1.2.0 and now I get a "Class 'Twig_Extension_Debug' not found" message. Filename: path\to\app\application\libraries\Twig.php 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: 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' |