Using Laravel 8.75 and trying to upgrade to php 8.1 in composer.json to "php": "^8.1" and receive the error of Illuminate\Contracts\Container\BindingResolutionException - Target class [CommandMakeCommand] does not exist.
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it.
Use symfony/mailer instead.
Generating optimized autoload files
Illuminate\Foundation\ComposerScripts::postAutoloadDump
#php artisan package:discover --ansi
Illuminate\Contracts\Container\BindingResolutionException
Target class [CommandMakeCommand] does not exist.
at
vendor/laravel/framework/src/Illuminate/Container/Container.php:879
875▕
876▕ try {
877▕ $reflector = new ReflectionClass($concrete);
878▕ } catch (ReflectionException $e) {
879▕ throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
880▕ }
881▕
882▕ // If the type is not instantiable, the developer is attempting to resolve
883▕ // an abstract type such as an Interface or Abstract Class and there is
+13 vendor frames
14 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
Script #php artisan package:discover --ansi handling the post-autoload-
dump event returned with error code 1
i also had same problem, in my case nwidart/laravel-modules package upgraded to 8.3 version, i downgraded to 8.2 version and problem solved
see here: https://docs.laravelmodules.com/v9/introduction
If you have an existing config file, and you get an error:
Target class [CommandMakeCommand] does not exist
Then the config file will need updating first import the commands class:
use Nwidart\Modules\Commands;
Next replace the commands array with:
'commands' => [
Commands\CommandMakeCommand::class,
Commands\ComponentClassMakeCommand::class,
Commands\ComponentViewMakeCommand::class,
Commands\ControllerMakeCommand::class,
Commands\DisableCommand::class,
Commands\DumpCommand::class,
Commands\EnableCommand::class,
Commands\EventMakeCommand::class,
Commands\JobMakeCommand::class,
Commands\ListenerMakeCommand::class,
Commands\MailMakeCommand::class,
Commands\MiddlewareMakeCommand::class,
Commands\NotificationMakeCommand::class,
Commands\ProviderMakeCommand::class,
Commands\RouteProviderMakeCommand::class,
Commands\InstallCommand::class,
Commands\ListCommand::class,
Commands\ModuleDeleteCommand::class,
Commands\ModuleMakeCommand::class,
Commands\FactoryMakeCommand::class,
Commands\PolicyMakeCommand::class,
Commands\RequestMakeCommand::class,
Commands\RuleMakeCommand::class,
Commands\MigrateCommand::class,
Commands\MigrateRefreshCommand::class,
Commands\MigrateResetCommand::class,
Commands\MigrateRollbackCommand::class,
Commands\MigrateStatusCommand::class,
Commands\MigrationMakeCommand::class,
Commands\ModelMakeCommand::class,
Commands\PublishCommand::class,
Commands\PublishConfigurationCommand::class,
Commands\PublishMigrationCommand::class,
Commands\PublishTranslationCommand::class,
Commands\SeedCommand::class,
Commands\SeedMakeCommand::class,
Commands\SetupCommand::class,
Commands\UnUseCommand::class,
Commands\UpdateCommand::class,
Commands\UseCommand::class,
Commands\ResourceMakeCommand::class,
Commands\TestMakeCommand::class,
Commands\LaravelModulesV6Migrator::class,
],
Just add this line:
use Nwidart\Modules\Commands\CommandMakeCommand;
in first of config/modules.php file as a namespace
Above namespace will resolve only commandMakeCommand issue, but if you want to set all command namespace then you need to add the namespace at the top.
namespace Nwidart\Modules\Commands;
Hope this helps (backup your project first):
First remove nwidart/laravel-modules by running: composer remove nwidart/laravel-modules
Then remove config/modules.php by deleting it.
Reinstall nwidart/laravel-modules by running: composer require nwidart/laravel-modules
Source:
Githubhot, the answer by mohamedsharaf
If someone is still looking for the answer so follow these steps
As mentioned in this link see here: https://docs.laravelmodules.com/v9/introduction
If you have an existing config file, and you get an error:
Target class [CommandMakeCommand] does not exist
Then the config file will need updating first import the commands class, and in your config folder update the modules.php file includes
use Nwidart\Modules\Commands;
Then replace the commands array with: add Commands\ before each value or simple copy and replace the array
'commands' => [
Commands\CommandMakeCommand::class,
Commands\ComponentClassMakeCommand::class,
Commands\ComponentViewMakeCommand::class,
Commands\ControllerMakeCommand::class,
Commands\DisableCommand::class,
Commands\DumpCommand::class,
Commands\EnableCommand::class,
Commands\EventMakeCommand::class,
Commands\JobMakeCommand::class,
Commands\ListenerMakeCommand::class,
Commands\MailMakeCommand::class,
Commands\MiddlewareMakeCommand::class,
Commands\NotificationMakeCommand::class,
Commands\ProviderMakeCommand::class,
Commands\RouteProviderMakeCommand::class,
Commands\InstallCommand::class,
Commands\ListCommand::class,
Commands\ModuleDeleteCommand::class,
Commands\ModuleMakeCommand::class,
Commands\FactoryMakeCommand::class,
Commands\PolicyMakeCommand::class,
Commands\RequestMakeCommand::class,
Commands\RuleMakeCommand::class,
Commands\MigrateCommand::class,
Commands\MigrateRefreshCommand::class,
Commands\MigrateResetCommand::class,
Commands\MigrateRollbackCommand::class,
Commands\MigrateStatusCommand::class,
Commands\MigrationMakeCommand::class,
Commands\ModelMakeCommand::class,
Commands\PublishCommand::class,
Commands\PublishConfigurationCommand::class,
Commands\PublishMigrationCommand::class,
Commands\PublishTranslationCommand::class,
Commands\SeedCommand::class,
Commands\SeedMakeCommand::class,
Commands\SetupCommand::class,
Commands\UnUseCommand::class,
Commands\UpdateCommand::class,
Commands\UseCommand::class,
Commands\ResourceMakeCommand::class,
Commands\TestMakeCommand::class,
Commands\LaravelModulesV6Migrator::class,
],
You can try to downgrade nwidart/laravel-modules version in composer.json file. Just change this line to the below line.
"nwidart/laravel-modules": "8.2.*"
Then delete composer.lock file and now, run this command.
composer install
If previous reply doesn't work for you,
If still not work after changing the version in composer.json as well as deleting the composer.lock and vendors, you can fix the version like this
"nwidart/laravel-modules": "8.2.*"
delete composer.lock and vendor and run
composer install
This Is Not Related Routes Or Any Other Parts Of Your App ,
When You Cant Run Composer Update Or Artisan Commands
You Have Problem In Booting Laravel , In This Case :
Go To Your Config Folder Open Modules File And Check "Command" Key
My Problem Fixed By This Way !
Good Day !
Error itself:
2021-07-20T23:43:33.993462+00:00 app[web.1]: [20-Jul-2021 23:43:33 UTC] [critical] Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\ClassNotFoundError: "Attempted to load class "SQLite3Cache" from namespace "Doctrine\Common\Cache".
2021-07-20T23:43:33.993688+00:00 app[web.1]: Did you forget a "use" statement for another namespace?" at /app/src/Utils/FilesCache.php line 23
The file contents of "FilesCache.php" are similar to what's provided in Symfony's documentation here with a few additions.
<?php
namespace App\Utils;
use App\Utils\Interfaces\CacheInterface;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Doctrine\Common\Cache\CacheProvider;
use Doctrine\Common\Cache\SQLite3Cache;
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
class FilesCache implements CacheInterface
{
public $cache;
public function __construct()
{
//this is error line 23
$provider = new SQLite3Cache(new \SQLite3(__DIR__ . '/cache/data.db'), 'TableName');
$this->cache = new TagAwareAdapter(
new DoctrineAdapter(
$provider,
$namespace = '',
$defaultLifetime = 0
)
);
}
}
I've added both "pdo_sqlite" and "sqlite3" extensions to "composer.json".
Composer update runs without issue.
I'm committing both the "composer.json" and "composer.lock" before pushing the local project repo to Heroku, which runs without issue as well and shows that both extensions are added.
remote: -----> Installing platform packages...
remote: - php (8.0.8)
remote: - ext-intl (bundled with php)
remote: - ext-pdo_sqlite (bundled with php)
remote: - ext-sqlite3 (bundled with php)
remote: - composer (2.1.3)
remote: - apache (2.4.48)
remote: - nginx (1.20.1)
I know that SQLite isn't the proper choice for a production database, I'm following a course and I'd like to continue using what's provided from it.
Thank you in advance for any help!
As mentioned in the comments, the problem was the deprecation of doctrine/cache. I switched to a PDOAdapter and this fixed the issue.
<?php
namespace App\Utils;
use App\Utils\Interfaces\CacheInterface;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\Cache\Adapter\PdoAdapter;
use Doctrine\DBAL\Driver\Connection;
class FilesCache implements CacheInterface
{
public $cache;
public function __construct()
{
$connection = \Doctrine\DBAL\DriverManager::getConnection([
'url' => 'sqlite:////%kernel.project_dir%/var/cache/data.db'
]);
$this->cache = new TagAwareAdapter(
new PdoAdapter(
$connection,
$namespace = '',
$defaultLifetime = 0
)
);
}
}
I try to run Flysystem's basic example code for the Local adapter and get a Class 'League\Flysystem\Adapter\Local' not found error. This is my process:
version check:
php -v
PHP 5.5.9-1ubuntu4.23 (cli) (built: Feb 8 2018 21:59:47)
install Flysystem:
composer require league/flysystem
output shows I'm up-to-date (this is my 2nd time running it):
Using version ^1.0 for league/flysystem
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
now there's a vendor folder in web root. And within ./web/vendor/league/flysystem/src/Adapter$ are these files:
AbstractAdapter.php
AbstractFtpAdapter.php
CanOverwriteFiles.php
Ftpd.php
Ftp.php
Local.php
NullAdapter.php
Polyfill/
SynologyFtp.php
...just showing that it seems to be installed correctly(?) I create one test file and one test directory in my web root:
fly-local.php
myfiles/
Into fly-local.php I paste the text from their docs (https://flysystem.thephpleague.com/docs/adapter/local/):
<?php
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
$adapter = new League\Flysystem\Adapter\Local(__DIR__.'/myfiles');
$filesystem = new Filesystem($adapter);
...and change the adapter's root folder to myfiles (is that correct?). Then I run it:
php fly-local.php
It outputs:
PHP Fatal error: Class 'League\Flysystem\Adapter\Local' not found in /[PROJECT DIR]/web/fly-local.php on line 6
PHP Stack trace:
PHP 1. {main}() /[PROJECT DIR]/web/fly-local.php:0
What am I doing wrong?
You used composer, then you need to include the composer autoload.php file.
The fly-local.php should be:
<?php
require __DIR__.'/vendor/autoload.php';
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
$adapter = new League\Flysystem\Adapter\Local(__DIR__.'/myfiles');
$filesystem = new Filesystem($adapter);
If you use a framework, you can see it includes the autoload php file for you (index.php, in general). If your test/custom file is not included to framework, you need to include the file manually.
I'm trying to transition a Laravel 4.2 site from Forge to Forge/Envoyer. I'm following the laracast but I keep getting the error:
PHP Fatal error: Class 'Way\Generators\GeneratorsServiceProvider' not
found in
/home/forge/Site/envoyer/releases/20150511192402/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php
on line 157
on the Install Composer Dependencies step of Envoyer deployment.
I've removed the lines for Way/Generators from both composer.json and config/app.php and have followed the documentation to re-install it. Envoyer works with Way/Generators removed but keeps failing when I add it back.
Anyone have any ideas on how to fix it?
In composer.json add way/generators inside "require-dev", so it will be downloaded only on your dev machine.
"require-dev": {
"way/generators": "~2.0"
}
Add Way\Generators\GeneratorsServiceProvider only inside your local (development) config - config/local/app.php. That way it will be present on your development machine, because it will use config/local/app.php, but while deploying, envoyer will use config/app.php, where Way\Generators\GeneratorsServiceProvider are not set.
This is how your config/local/app.php can look like:
<?php
return array(
'debug' => true,
'providers' => append_config(array(
'Way\Generators\GeneratorsServiceProvider'
))
);
Help me out here....
I have installed wkhtml2pdf 0.9.9 static for mac os and installed it in the /usr/bin. Wkhtml2pdf works fine from the terminal, with the wkhtmltopdf [source website][generated file to be saved].
Though I am unable to use it in Symfony 2.3.7, with the knpSnappy and knpSnappyBundle installed. I am sure I have entered everything correctly. I have checked it a million times and searched all of the google and yet couldnt find why it would do that (been searching for two days.
I have downloaded knpSnappy and knpSnappyBundle through composer and it is in the vendor and as well as enabled in the config.yml and added to appkernel.php, other than that Following is my configuration:
Composer:
"knplabs/knp-snappy-bundle": "dev-master",
"knplabs/knp-snappy": "*"
Appkernel:
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
Controller:
public function generateAction($date)
{
$em = $this->getDoctrine()->getManager();
$publishedAds = $em->getRepository('pdfRenderAdBundle:Ads')
->getAllAds();
if (!$publishedAds) {
throw $this->createNotFoundException(
'No ads found for today!'
);
}
$html = $this->renderView('pdfRenderAdBundle:Application:generate.html.twig', array(
'publishedAds' => $publishedAds
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
400,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
}
SYMFONY VER: 2.3.7
WKHTMLTOPDF: 0.9.9 STATIC OSX KNPSNAPPY LIB &
KNPSNAPPY BUNDLE: THE LATEST ONE THROUGH SYMFONY
Whenever I try to access the controller it gives the:
The process has been signaled with signal "5" - 500 Internal Server Error - RuntimeException
I will really appreciate it if any one of you can help out of this well..... Stuck here for a very long time now.
For anyone else that comes across this, here's the post on how to get this working:
http://oneqonea.blogspot.com/2012/04/why-does-wkhtmltopdf-work-via-terminal.html
Here's the short version:
Comment out the following line in /Applications/MAMP/Library/bin/envvars
#export DYLD_LIBRARY_PATH
And then add this line:
export PATH=/parent/path/of/wkhtmltopdf/executable:$PATH
I had this problem as well, and if IIRC the solution was to use wkhtmltopdf version 0.9.6.