Cannot find existing key in array - php

I'm working with composer and I have the following classmap:
return array(
'Wit\\Cache\\CacheAdapterInterface' => $baseDir . '/src/Wit/Cache/CacheAdapterInterface.php',
'Wit\\Cache\\CacheManager' => $baseDir . '/src/Wit/Cache/CacheManager.php',
'Wit\\Cache\\FileAdapter' => $baseDir . '/src/Wit/Cache/FileAdapter.php',
'Wit\\Cache\\RedisAdapter' => $baseDir . '/src/Wit/Cache/RedisAdapter.php',
'Wit\\Request\\Request' => $baseDir . '/src/Wit/Request/Request.php',
'Wit\\Zenpoint\\ZenpointUser' => $baseDir . '/src/Wit/Zenpoint/ZenpointUser.php',
'Wit\\Zenpoint\\ZenpointConfig' => $baseDir . '/src/Wit/Zenpoint/ZenpointConfig.php',
'Wit\\Zenpoint\\ZenpointCarrello' => $baseDir . '/src/Wit/Zenpoint/ZenpointCarrello.php',
'Wit\\Zenpoint\\ZenpointAcquisitions' => $baseDir . '/src/Wit/Zenpoint/ZenpointAcquisitions.php',
'Wit\\Zenpoint\\ZenpointAcquisition' => $baseDir . '/src/Wit/Zenpoint/ZenpointAcquisition.php',
'Wit\\Cart\\ZipCodeChecker' => $baseDir . '/src/Wit/Cart/ZipCodeChecker.php',
'Wit\\Cart\\ZipCodeLoader' => $baseDir . '/src/Wit/Cart/ZipCodeLoader.php',
'Wit\\Complimentary\\OmaggioOrdine' => $baseDir . '/src/Wit/Complimentary/OmaggioOrdine.php',
'Wit\\Complimentary\\PacchettoOmaggio' => $baseDir . '/src/Wit/Complimentary/PacchettoOmaggio.php',
'Wit\\Complimentary\\ProdottiAScelta' => $baseDir . '/src/Wit/Complimentary/ProdottiAScelta.php',
'Wit\\Complimentary\\OmaggioLoader' => $baseDir . '/src/Wit/Complimentary/OmaggioLoader.php',
'Wit\\Complimentary\\PacchettoLoader' => $baseDir . '/src/Wit/Complimentary/PacchettoLoader.php',
'Wit\\Complimentary\\ProdottiASceltaLoader' => $baseDir . '/src/Wit/Complimentary/ProdottiASceltaLoader.php',
'Wit\\Complimentary\\ProdottiLoader' => $baseDir . '/src/Wit/Complimentary/ProdottiLoader.php',
);
I then have the following in a file: use WIT\Complimentary\OmaggioLoader;
The problem is that PHP says it cannot find the class:
Fatal error: Class 'WIT\ComplimentaryProducts\OmaggioLoader' not found.
The first thing I thought was that the path was wrong, but it doesn't seem so. So I tried to see what was happening in the Composer ClassLoader.php file and dumped the following:
var_dump($class); //string(31) "WIT\Complimentary\OmaggioLoader"
var_dump(array_keys($this->classMap)); //[15]=> string(31) "Wit\Complimentary\OmaggioLoader"
var_dump(array_key_exists($class, $this->classMap)); //bool(false)
var_dump($this->classMap[$class]); //NULL
var_dump($this->classMap['Wit\\Complimentary\\OmaggioLoader']);//string(69) "/path/to/Wit/Complimentary/OmaggioLoader.php"
So, why PHP cannot find the array element if the key is correct? Why if I insert it manually, will PHP finds it?

Class names in PHP are case insensitive, array keys are not. They have different beginning.

Related

Cannot Php artisan serve cause of cannot redeclare class Composer

I can't run using php artisan serve cause of :
PHP Fatal error: Cannot redeclare class Composer\Autoload\ComposerStaticInit4783eae8fdb0bbd7059e05caa6aed997 in /var/www/html/project/config/vendor/composer/autoload_static.php
Script php artisan optimize handling the post-update-cmd event returned with error code 255
Heres is my autoload_static.php:
class ComposerStaticInit57efd0b78daf784a291fa20fc5e6edcd
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
'1d1b89d124cc9cb8219922c9d5569199' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
'3919eeb97e98d4648304477f8ef734ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
'5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
'bd9634f2d41831496de0d3dfe4c94881' => __DIR__ . '/..' . '/symfony/polyfill-php56/bootstrap.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'e7223560d890eab89cda23685e711e2c' => __DIR__ . '/..' . '/psy/psysh/src/Psy/functions.php',
'f18cc91337d49233e5754e93f3ed9ec3' => __DIR__ . '/..' . '/laravelcollective/html/src/helpers.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'f0906e6318348a765ffb6eb24e0d0938' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php',
);
}
already try composer install and update but still didnt work at all. anyone know ?
So the problem is wrong step while compose require internvention/image. i didnt check the app/config.php first. should comment the provider and the aliases. i think the case is solve. thank you everyone.

How to use Zend Framework 1 when is installed through composer?

Recently I discovered that Zend Framework 1 (ZF1) can be installed using composer so I did a: composer require zendframework/zendframework1. That change my composer.json by adding the following:
{
...
"autoload": {
"psr-0": { "": ["application/models", "application/controllers", "application/forms"]},
"psr-4": { "": ["src/", "library/"]}
},
"require": {
...
"zendframework/zendframework1": "^1.12"
}
}
After run the command composer update and composer dump-autoload I look into the composer generated files and I can see the following:
/vendor/composer/autoload_files.php
===================================
// autoload_files.php #generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'92c8763cd6170fce6fcfe7e26b4e8c10' => $vendorDir . '/symfony/phpunit-bridge/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'b067bc7112e384b61c701452d53a14a8' => $vendorDir . '/mtdowling/jmespath.php/src/JmesPath.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'8a9dc1de0ca7e01f3e08231539562f61' => $vendorDir . '/aws/aws-sdk-php/src/functions.php',
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'023d27dca8066ef29e6739335ea73bad' => $vendorDir . '/symfony/polyfill-php70/bootstrap.php',
'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
'6a47392539ca2329373e0d33e1dba053' => $vendorDir . '/symfony/polyfill-intl-icu/bootstrap.php',
'32dcc8afd4335739640db7d200c1971d' => $vendorDir . '/symfony/polyfill-apcu/bootstrap.php',
'3a37ebac017bc098e9a86b35401e7a68' => $vendorDir . '/mongodb/mongodb/src/functions.php',
);
/vendor/composer/autoload_namespaces.php
===================================
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Zend_' => array($vendorDir . '/zendframework/zendframework1/library'),
'Twig_' => array($vendorDir . '/twig/twig/lib'),
'SensioLabs\\Security' => array($vendorDir . '/sensiolabs/security-checker'),
'Doctrine\\ORM\\' => array($vendorDir . '/doctrine/orm/lib'),
'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib'),
'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'),
'' => array($baseDir . '/application/models', $baseDir . '/application/controllers', $baseDir . '/application/forms'),
);
/vendor/composer/include_paths.php
===================================
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
$vendorDir . '/zendframework/zendframework1/library',
);
I am trying to use then the class from the application/bootstrap.php file as for example:
use Zend_Config_Ini;
$config = new Zend_Config_Ini('./../config/config.ini', 'general');
But PHP is complaining with the following error:
PHP Fatal error: Uncaught Error: Class 'Zend_Config_Ini' not found in
/var/www/html/application/bootstrap.php:23
Why? What I am missing here?
That are composer basics, you need to include the autoloader file to be able to load those classes.
require __DIR__ . '/vendor/autoload.php';

Symfony autoloading a namespace on every controller

I have already seen that there is an autoload_namespace.php file in Symfony but I cant seem to get it to work.
I want to autoload the: Symfony\Component\HttpFoundation\Session\Session namespace.
Here is the autoload_namespace.php so far
<?php
// autoload_namespaces.php #generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Twig_' => array($vendorDir . '/twig/twig/lib'),
'SensioLabs\\Security' => array($vendorDir . '/sensiolabs/security-checker'),
'Psr\\Log\\' => array($vendorDir . '/psr/log'),
'Doctrine\\ORM\\' => array($vendorDir . '/doctrine/orm/lib'),
'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib'),
'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'),
'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'),
//this is the session namespace i want to auto include
'Symfony\\Component\\HttpFoundation\\Session\\Session\\' => array($vendorDir . '/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Session.php')
);
Thanks

creating a zf2 module without controllers with some autoloaded classes

I'm trying to create a Zend Framework 2 module that has some generic classes that I want to use in some of my controllers.
I created a directory called 'tux-drink-zf2-module' in 'vendor' directory.
I added that directory to 'application.config.php'.
my Module.php has the following:
<?php
namespace TuxDrink;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
class Module implements AutoloaderProviderInterface
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}
update
new:
my autoload_classmap.php has the following:
<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
'TuxDrink\Module' => __DIR__ . '/Module.php',
'TuxDbCassandra' => __DIR__ . '/src/TuxDrink/TuxDb/Cassandra/TuxDbCassandra.php',
'TuxDrink\Drink\Model\AlcoholSum' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/AlcoholSum.php',
'TuxDrink\Drink\Model\AlcoholSumTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/AlcoholSumTable.php',
'TuxDrink\Drink\Model\Drink' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/Drink.php',
'TuxDrink\Drink\Model\DrinkBrand' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkBrand.php',
'TuxDrink\Drink\Model\DrinkBrandTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkBrandTable.php',
'TuxDrink\Drink\Model\DrinkCompany' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkCompany.php',
'TuxDrink\Drink\Model\DrinkCompanyTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkCompanyTable.php',
'TuxDrink\Drink\Model\DrinkFlavor' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkFlavor.php',
'TuxDrink\Drink\Model\DrinkFlavorTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkFlavorTable.php',
'TuxDrink\Drink\Model\DrinkFlavorType' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkFlavorType.php',
'TuxDrink\Drink\Model\DrinkFlavorTypeTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkFlavorTypeTable.php',
'TuxDrink\Drink\Model\DrinkIngredient' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkIngredient.php',
'TuxDrink\Drink\Model\DrinkIngredientTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkIngredientTable.php',
'TuxDrink\Drink\Model\DrinkIngredientType' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkIngredientType.php',
'TuxDrink\Drink\Model\DrinkIngredientTypeTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkIngredientTypeTable.php',
'TuxDrink\Drink\Model\DrinkTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkTable.php',
'TuxDrink\Drink\Model\DrinkType' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkType.php',
'TuxDrink\Drink\Model\DrinkTypeTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/DrinkTypeTable.php',
'TuxDrink\Drink\Model\GlobalImage' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImage.php',
'TuxDrink\Drink\Model\GlobalImageLink' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageLink.php',
'TuxDrink\Drink\Model\GlobalImageLinkPending' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageLinkPending.php',
'TuxDrink\Drink\Model\GlobalImageLinkPendingTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageLinkPendingTable.php',
'TuxDrink\Drink\Model\GlobalImageLinkTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageLinkTable.php',
'TuxDrink\Drink\Model\GlobalImageTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageTable.php',
'TuxDrink\Drink\Model\GlobalImageType' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageType.php',
'TuxDrink\Drink\Model\GlobalImageTypeTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/GlobalImageTypeTable.php',
'TuxDrink\Drink\Model\LiquidColor' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/LiquidColor.php',
'TuxDrink\Drink\Model\LiquidColorTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/LiquidColorTable.php',
'TuxDrink\Drink\Model\LiquidColorType' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/LiquidColorType.php',
'TuxDrink\Drink\Model\LiquidColorTypeTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/LiquidColorTypeTable.php',
'TuxDrink\Drink\Model\PendingDrinkCommits' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/PendingDrinkCommits.php',
'TuxDrink\Drink\Model\PendingDrinkCommitsTable' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Model/PendingDrinkCommitsTable.php',
'TuxDrink\TuxDb\Mysql\Drink\TuxDbMysqlDrink' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/TuxDbMysqlDrink.php',
'TuxDrink\TuxDb\Drink\Util\AlcoholCalc' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/Drink/Util/AlcoholCalc.php',
'TuxDrink\TuxDb\Mysql\TuxDbMysql' => __DIR__ . '/src/TuxDrink/TuxDb/Mysql/TuxDbMysql.php',
'TuxDrink\TuxDb\TuxDbAbstract' => __DIR__ . '/src/TuxDrink/TuxDb/TuxDbAbstract.php',
'TuxDrink\TuxDb\TuxDbInterface' => __DIR__ . '/src/TuxDrink/TuxDb/TuxDbInterface.php',
'TuxDrink\TuxDb\TuxDrinkInterface' => __DIR__ . '/src/TuxDrink/TuxDb/TuxDrinkInterface.php',
'TuxDrink\TuxDb\TuxTableInterface' => __DIR__ . '/src/TuxDrink/TuxDb/TuxTableInterface.php',
);
but still when I try to refresh my project I get the following error:
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (tux-drink-zf2-module) could not be initialized.' in /Volumes/2g-storage/projects/php-projects/myalcoholist/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php on line 144
maybe i'm missing some other files in order to properly configure this as a Module?
remember, this is a package for sources, without controllers, views and actions.
any information regarding the issue would be greatly appreciated.
update
this issue was solved when i fixed the directories structure.
but when I'm trying to use the module in one the the controllers.
in my case i need to use two classes from the TuxDrink module.
class 'TuxDbMysqlDrink' and class 'TuxDbMysql'.
I need to use them in controller 'DrinkController' in action 'drink-brand-autocomplete'.
I use the following code:
use \TuxDb\Mysql\Drink\TuxDbMysqlDrink;
use \TuxDb\Mysql\TuxDbMysql;
public function drinkBrandAutocompleteAction() {
$param=$this->getRequest()->getQuery('q');
if ($param) {
$drink = new TuxDbMysqlDrink();
$result=$drink->autoCompleteDrinkBrand($param);
return $result;
}
}
and I get the following error message:
Fatal error: DrinkManagement\Controller\DrinkController cannot use TuxDrink\TuxDb\Mysql\Drink\TuxDbMysqlDrink - it is not a trait in /Volumes/2g-storage/projects/php-projects/myalcoholist/module/DrinkManagement/src/DrinkManagement/Controller/DrinkController.php on line 197
any ideas?
tried to google, couldn't understand what it means "it is not a trait"
update
resolved it with this code:
public function drinkBrandAutocompleteAction() {
$param=$this->getRequest()->getQuery('q');
if ($param) {
$drink = new \TuxDrink\TuxDb\Mysql\Drink\TuxDbMysqlDrink();
$result=$drink->autoCompleteDrinkBrand($param);
die(var_export($result,1));
...
Going by the error, the Module name is tux-drink-zf2-module. Taking sanitization into account, i'll assume your module is CamelCased like TuxDrinkZf2Module. Therefore the namespace you're assigning inside Module.php doesn't match, as it's only TuxDrink.
So my guess would be, either of your names is incorrect.

Symfony 2.1 Extending Core Classes

I am trying to override the core Symfony components with my own. The method I am using is:
"autoload": {
"psr-0": {
"": "src/",
"Symfony": "src/vendor/symfony/src/"
}
}
However when I run composer update and install it never seems to take this into account. Is this not the correct method to force the autoloader to look into another directory first before the Symfony core?
Any pointers appreciated!
EDIT: Paths to files
src/vendor/symfony/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
src/vendor/symfony/src/Symfony/Component/Translation/Translator.php
src/vendor/symfony/src/Symfony/Component/Translation/Loader/YamlFileLoader.php
<?php
// autoload_namespaces.php generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Twig_Extensions_' => $vendorDir . '/twig/extensions/lib/',
'Twig_' => $vendorDir . '/twig/twig/lib/',
'Symfony\\Bundle\\SwiftmailerBundle' => $vendorDir . '/symfony/swiftmailer-bundle/',
'Symfony\\Bundle\\MonologBundle' => $vendorDir . '/symfony/monolog-bundle/',
'Symfony\\Bundle\\AsseticBundle' => $vendorDir . '/symfony/assetic-bundle/',
'Symfony' => array($vendorDir . '/symfony/symfony/src/', '/src/vendor/symfony/src/'),
'SessionHandlerInterface' => $vendorDir . '/symfony/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs',
'Sensio\\Bundle\\GeneratorBundle' => $vendorDir . '/sensio/generator-bundle/',
'Sensio\\Bundle\\FrameworkExtraBundle' => $vendorDir . '/sensio/framework-extra-bundle/',
'Sensio\\Bundle\\DistributionBundle' => $vendorDir . '/sensio/distribution-bundle/',
'Monolog' => $vendorDir . '/monolog/monolog/src/',
'Metadata\\' => $vendorDir . '/jms/metadata/src/',
'JMS\\SecurityExtraBundle' => $vendorDir . '/jms/security-extra-bundle/',
'JMS\\DiExtraBundle' => $vendorDir . '/jms/di-extra-bundle/',
'JMS\\AopBundle' => $vendorDir . '/jms/aop-bundle/',
'Doctrine\\ORM' => $vendorDir . '/doctrine/orm/lib/',
'Doctrine\\DBAL' => $vendorDir . '/doctrine/dbal/lib/',
'Doctrine\\Common' => $vendorDir . '/doctrine/common/lib/',
'Doctrine\\Bundle\\DoctrineBundle' => $vendorDir . '/doctrine/doctrine-bundle/',
'CG\\' => $vendorDir . '/jms/cg/src/',
'Assetic' => $vendorDir . '/kriswallsmith/assetic/src/',
'' => $baseDir . '/src/',
);
If I manually edit the autoload line to:
'Symfony' => array('/Users/macbook/Sites/Opia/Gaia/src/vendor/symfony/src/', $vendorDir . '/symfony/symfony/src/'),
Everything works as it is meant to. So now it is basically finding the solution to why composer does not compose properly.
EDIT 2:
Doing some more searching it appears the above method is not a good implementation:
https://groups.google.com/forum/#!msg/composer-dev/HprRV_wJZg4/M_zQ8O7lB6IJ
Instead I need to extend the given classes and tell Symfony to use those classes instead which should be possible through the parameters:
parameters:
security.authentication.listener.anonymous.class: Acme\DemoBundle
\Security\Http\Firewall\AcmeAnonymousAuthenticationListener
However I am not sure what parameters I need to set to load the extended classes in place of the core.
I finally found the answer to this.
Firstly if you need to find out which classes to override go to:
symfony/src/Symfony/Bundle/FrameworkBundle/Resources/%Your file to override%.xml
There you will find a list of possible Symfony classes that can be extended/overridden.
Then in your config.yml add (I chose to put mine in an extend namespace):
parameters:
twig.extension.trans.class: Extend\Symfony\Bridge\Twig\Extension\TranslationExtension
translation.loader.yml.class: Extend\Symfony\Component\Translation\Loader\YamlFileLoader
translator.class: Extend\Symfony\Bundle\FrameworkBundle\Translation\Translator
Finally in my composer.json:
"autoload": {
"psr-0": {
"": "src/",
"Extend\\Symfony": "/path/to/your/symfony/classes"
}
},

Categories