A while ago I created a twig extension. Recently I added a namespace so I could use it with composer more easily. I've done this a few times and it works fine with other files/classes.
The problem is that it only autoloads properly if I use the -o option (optimize) when I update or dumpautoload in composer.
So for example if I run composer dumpautoload -o
my class is found with no issues. If I run composer dumpautoload
it will NOT work and give me the following error:
Fatal error: Class 'Crecket\custom_twig_extension' not found in C:\Dropbox\Ampps\www\crecket.dev\index.php on line 24
My extension class:
namespace Crecket;
class custom_twig_extension extends \Twig_Extension{
// The code
}
My composer file
"autoload": {
"psr-4": {
"Crecket\\": "src/"
}
}
Folder structure
src/custom_twig_extension.php
Does anyone know what is causing this? I can't seem to figure out what is causing this. I'm guessing it has to do with composer creating a classmap when I use optimize.