1
votes

using composer in a Php project, with Twig and my own framework.

I would like to "override" the Twig_Node_Expression_GetAttr class from Twig with my own class.

Everything it's working fine, but I have to manually add in composer autoload_classmap.php file :

'Twig_Node_Expression_GetAttr' => 'ebuildy/ebuildy/src/eBuildy/Templating/Twig_Node_Expression_GetAttr.php',

How can I declare this in my composer.json description file ?

Thanks,

1

1 Answers

2
votes

You can just define the classmap entry in your project's composer.json, or using PSR-0 mapping as well. See the composer docs on autoloading for details. If you define the PSR-0 namespace with a more restrictive namespace than what Twig has, then you're sure yours will take over, .e.g:

{
    "autoload": {
        "psr-0": {
            "Twig_Node_": "path/to/src/"
        }
    }
}

This however only works if in this src/ dir you have a file called: src/Twig/Node/Expression/GetAttr.php.