What causes the “Twig_Environment not found” error? |
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?
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 What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-19-2020, 05:05 PM)InsiteFX Wrote: The library should be installed in the ThridParty folder.
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. (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! PHP Code: @trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(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 (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' |
Welcome Guest, Not a member yet? Register Sign In |