I have "inherited" a project that has a git dependency I do not have access to. I have the contents of the whole /vendor directory and want to move the dependency out of it so that I do not need to commit the whole /vendor directory to git. I have moved the directory with the dependency to /my-vendor directory (at the same level as vendor), but have no idea how to include it into the project.
When running composer install I get:
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "MY_BUNDLE_CLASS" from namespace "DEP_NAME\MY_BUNDLE".
Did you forget a "use" statement for another namespace? in /app/app/AppKernel.php:40
Stack trace:
#0 /app/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(406): AppKernel->registerBundles()
#1 /app/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(113): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /app/app/AppKernel.php(21): Symfony\Component\HttpKernel\Kernel->boot()
#3 /app/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(137): AppKernel->boot()
#4 /app/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(124): Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands()
#5 /app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(89): Symfony\Bundle\FrameworkBundle\Console\Application->add(Object(Symfony\Component\Console in /app/app/AppKernel.
php on line 40
MY_BUNDLE_CLASS, DEP_NAME, and MY_BUNDLE being edited.
You can place those bundles in bundle directory, for example, and then add to composer.json following lines:
"repositories": [
{
"type" : "path",
"url" : "./bundles/your-bundle"
}
]
Related
I am upgrading laravel from 5.5.* to 5.6.0. Composer install ran fine. I am trying to run unit tests upon which this error is popping up.
Class '..\Unit\UnitTestCase' not found
This is the stack trace of the error:
Fatal error: Uncaught Error: Class 'PhiraterTest\Unit\UnitTestCase'
not found in
/home/vagrant/code/phirater-l51/tests/unit/Phirater/AdditionalCurrencies/CreateAdditionalCurrencyCommandHandlerTest.php:11
Stack trace:
#0 /home/vagrant/code/phirater-l51/vendor/phpunit/phpunit/src/Util/Fileloader.php(64):
include_once()
#1 /home/vagrant/code/phirater-l51/vendor/phpunit/phpunit/src/Util/Fileloader.php(48):
PHPUnit\Util\Fileloader::load('/home/vagrant/c...')
#2 /home/vagrant/code/phirater-l51/vendor/phpunit/phpunit/src/Framework/TestSuite.php(325):
PHPUnit\Util\Fileloader::checkAndLoad('/home/vagrant/c...')
#3 /home/vagrant/code/phirater-l51/vendor/phpunit/phpunit/src/Framework/TestSuite.php(403):
PHPUnit\Framework\TestSuite->addTestFile('/home/vagrant/c...')
#4 /home/vagrant/code/phirater-l51/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php(65):
PHPUnit\Framework\TestSuite->addTestFiles(Array)
#5 /home/vagrant/code/phirater-l51/vendor/phpunit/phpunit/src/TextUI/Command.php(169):
PHPUnit\Runner\BaseTestRunner->getTest('tes in
/home/vagrant/code/phirater-l51/tests/unit/Phirater/AdditionalCurrencies/CreateAdditionalCurrencyCommandHandlerTest.php
on line 11
My unit tests are in tests/ directory. My UnitTestCase class in extended by \TestCase class and TestCase class is extended by BrowserKitTestCase. What am i doing wrong here? What could be the solution?
If your dependency class is really present and has proper namespace, then the most probable reasons of mentioned error are (avoid copying below examples to your project, that will definetely not work):
composer.json file (root directory) has no relevant record of the dependency (do not forget composer.lock file also), smth like:
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
as a result of above, vendor/autoload.php file (or any of its merged siblings, e.g. vendor/composer/autoload_classmap.php, depending on your case) can miss relevant record of the dependency, smth like:
return array(
'PHPUnit\\Framework\\TestCase' => '/vendor/phpunit/phpunit/src/Framework/TestCase.php',
In most such cases it is really a missed dependency delivered by autoload.php functionality, which in its turn caused by composer malfunctioning. So taking in account all that, try to update composer itself by running composer self-update, and then updating your dependencies by composer update.
I am fairly new to git and I am looking to clone a repo to XAMPP.
From what I understand I should be able to just clone it to HTDOCS and it should work if all the dependencies are installed.
I get this error message when I visit the project folder in my browser.
Fatal error: Uncaught Error: Call to a member function init() on null
in C:\xampp\htdocs\sandbox\craft\app\services\CacheService.php:114
Stack trace: #0
C:\xampp\htdocs\sandbox\craft\app\framework\base\CModule.php(394):
Craft\CacheService->init() #1
C:\xampp\htdocs\sandbox\craft\app\etc\web\WebApp.php(595):
CModule->getComponent('cache', true) #2
C:\xampp\htdocs\sandbox\craft\app\framework\base\CModule.php(103):
Craft\WebApp->getComponent('cache') #3
C:\xampp\htdocs\sandbox\craft\app\services\ConfigService.php(392):
CModule->__get('cache') #4
C:\xampp\htdocs\sandbox\craft\app\services\HttpRequestService.php(1181):
Craft\ConfigService->usePathInfo() #5
C:\xampp\htdocs\sandbox\craft\app\services\HttpRequestService.php(131):
Craft\HttpRequestService->getNormalizedPath() #6
C:\xampp\htdocs\sandbox\craft\app\framework\base\CModule.php(394):
Craft\HttpRequestService->init() #7
C:\xampp\htdocs\sandbox\craft\app\etc\web\WebApp.php(595):
CModule->getComponent('request', true) #8
C:\xampp\htdocs\sandbox\craft\app\framework\base\CMo in
C:\xampp\htdocs\sandbox\craft\app\services\CacheService.php on line
114
I know this a vague question but I'd appreciate any help.
Thank you
I think once you will clone the craft project from your git repo. You need to add .Env file into it. Then your need "uploads" folder. Also you should run the composer install command to install all the dependencies.
After all this process if you still getting the same error then you should try to remove cache from your runtime cache folder and also you can remove compiled classes and templates once.
I hope this will work.
when I try
composer dump-autoload
I get the following error on my linux machine
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
PHP Warning: Uncaught ErrorException: require(/App/Helpers/AppHelper.php): failed to open stream: No such file or directory in /var/www/page/vendor/composer/autoload_real.php:66
Stack trace:
#0 /var/www/page/vendor/composer/autoload_real.php(66): Composer\Util\ErrorHandler::handle(2, 'require(/App/He...', '/var/www/pag...', 66, Array)
#1 /var/www/page/vendor/composer/autoload_real.php(66): require()
#2 /var/www/page/vendor/composer/autoload_real.php(56): composerRequire14063f7e5e06d46e1f9f9d444238e903('ba1c657daf90253...', '/App/Helpers/Ap...')
#3 /var/www/page/vendor/autoload.php(7): ComposerAutoloaderInit14063f7e5e06d46e1f9f9d444238e903::getLoader()
#4 /var/www/page/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(43): require_once('/var/www/pag...')
#5 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(292): Illuminate\Foundation\ComposerScripts::postAutoloadDump(Object(Composer\Script\Event))
#6 phar:///usr/local/bin/com in /var/www/page/vendor/composer/autoload_real.php on line 66
Warning: Uncaught ErrorException: require(/App/Helpers/AppHelper.php): failed to open stream: No such file or directory in /var/www/page/vendor/composer/autoload_real.php:66
Stack trace:
#0 /var/www/page/vendor/composer/autoload_real.php(66): Composer\Util\ErrorHandler::handle(2, 'require(/App/He...', '/var/www/pag...', 66, Array)
#1 /var/www/page/vendor/composer/autoload_real.php(66): require()
#2 /var/www/page/vendor/composer/autoload_real.php(56): composerRequire14063f7e5e06d46e1f9f9d444238e903('ba1c657daf90253...', '/App/Helpers/Ap...')
#3 /var/www/page/vendor/autoload.php(7): ComposerAutoloaderInit14063f7e5e06d46e1f9f9d444238e903::getLoader()
#4 /var/www/page/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(43): require_once('/var/www/pag...')
#5 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(292): Illuminate\Foundation\ComposerScripts::postAutoloadDump(Object(Composer\Script\Event))
#6 phar:///usr/local/bin/com in /var/www/page/vendor/composer/autoload_real.php on line 66
PHP Fatal error: composerRequire14063f7e5e06d46e1f9f9d444238e903(): Failed opening required '/App/Helpers/AppHelper.php' (include_path='.:/usr/share/php') in /var/www/page/vendor/composer/autoload_real.php on line 66
Fatal error: composerRequire14063f7e5e06d46e1f9f9d444238e903(): Failed opening required '/App/Helpers/AppHelper.php' (include_path='.:/usr/share/php') in /var/www/page/vendor/composer/autoload_real.php on line 66
But when I do it on my windows machine its working fine.
The files Im trying to include are
"files": [
"App/Helpers/AppHelper.php",
"App/Helpers/CoinHiveApi.php",
"App/Helpers/CloudflareAPI.php"
]
Is there anyting I have to add/change?
In laravel, You need to gives proper path(without any letter cases change) of file /Directive.
When you are work with composer.json, .env, any provider etc you need to run below command because laravel create cache itself.
1) composer update (If you add new package)
2) composer dump-autoload (Why do I have to run "composer dump-autoload" command to make migrations work in laravel?)
3) php artisan cache:clear
4) php artisan view:clear(if you add new view)
As mentioned in the comments, case matters.
Composer takes file paths:
"files": [
"app/Helpers/AppHelper.php",
...
]
App !== app
The folder is app.
I'm trying to install an existing Laravel project by running a "composer install" command but i'm getting the following errors :
PHP Fatal error: Uncaught Error: Class 'Symfony\Thanks\Command\ThanksCommand' not found in /home/lyes/Documents/AppStage/vendor/symfony/thanks/src/Thanks.php:58
Stack trace:
#0 /usr/share/php/Composer/Plugin/PluginManager.php(236): Symfony\Thanks\Thanks->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
#1 /usr/share/php/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(Symfony\Thanks\Thanks))
#2 /usr/share/php/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
#3 /usr/share/php/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
#4 /usr/share/php/Composer/Factory.php(384): Composer\Plugin\PluginManager->loadInstalledPlugins()
#5 /usr/share/php/Composer/Factory.php(576): Composer\Factory->createComposer(Object(Composer\IO\ConsoleIO), Array, false)
#6 /usr/share/php/Composer/Console/Application.php(332): C in /home/lyes/Documents/AppStage/vendor/symfony/thanks/src/Thanks.php on line 58
Fatal error: Uncaught Error: Class 'Symfony\Thanks\Command\ThanksCommand' not found in /home/lyes/Documents/AppStage/vendor/symfony/thanks/src/Thanks.php:58
Stack trace:
#0 /usr/share/php/Composer/Plugin/PluginManager.php(236): Symfony\Thanks\Thanks->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
#1 /usr/share/php/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(Symfony\Thanks\Thanks))
#2 /usr/share/php/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
#3 /usr/share/php/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
#4 /usr/share/php/Composer/Factory.php(384): Composer\Plugin\PluginManager->loadInstalledPlugins()
#5 /usr/share/php/Composer/Factory.php(576): Composer\Factory->createComposer(Object(Composer\IO\ConsoleIO), Array, false)
#6 /usr/share/php/Composer/Console/Application.php(332): C in /home/lyes/Documents/AppStage/vendor/symfony/thanks/src/Thanks.php on line 58
Can anyone help me, I am really overwhelmed
Just delete vendor folder and than run composer update command
Try using composer update and composer dump-autoload command
When you run composer install it will look for a lock file and install whatever is contained in it. Check if your composer.lock or run composer update command
Try the following steps:
Remove the vendor folder if already there
Delete the composer.lock file
Run composer install command in the terminal.
I'm having trouble while deploying my symfony web app on heroku, when previously it worked just fine. What could be wrong?
This is the build log: http://pastebin.com/DXZH110S
Here is the relevant part of the log:
Generating optimized autoload files
Incenteev\ParameterHandler\ScriptHandler::buildParameters
Creating the "app/config/parameters.yml" file
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SensioGeneratorBundle" from namespace "Sensio\Bundle\GeneratorBundle".
Did you forget a "use" statement for another namespace? in /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/app/AppKernel.php:25
Stack trace:
#0 /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(403): AppKernel->registerBundles()
#1 /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(113): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()
#3 /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/vendor/symfony/symfony/src/Symfony/Component/Console/Appli in /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/app/AppKernel.php on line 25
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SensioGeneratorBundle" from namespace "Sensio\Bundle\GeneratorBundle".
Did you forget a "use" statement for another namespace? in /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/app/AppKernel.php:25
Stack trace:
#0 /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(403): AppKernel->registerBundles()
#1 /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(113): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()
#3 /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/vendor/symfony/symfony/src/Symfony/Component/Console/Appli in /tmp/build_d39105bc4146e68631d1261a1ca2a632/izio7-YourTeam-15b2d72/app/AppKernel.php on line 25
Finally I solved, the problem was the system variable SYMFONY_ENV=prod not set.
https://devcenter.heroku.com/articles/getting-started-with-symfony#configuring-symfony-to-run-in-the-prod-environment