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 !
undefined method
(Relevant files linked at the bottom of my question.)
I let Composer run some post-install-cmd and post-update-cmd scripts. In my script I want to make use of the readlink() function from symfony/filesystem. Inside my projects /vendor folder there is the 3.4 version of the filesystem package, fine.
I use Symfony\Component\Filesystem\Filesystem; at the top of my file.
But whenever I run:
$fs = new Filesystem();
$path = '/path/to/some/symlink';
if ($fs->readlink($path)) {
// code
}
I get the following error which tells me I'm calling an undefined method:
PHP Fatal error: Uncaught Error: Call to undefined method
Symfony\Component\Filesystem\Filesystem::readlink() in
/Users/leymannx/Sites/blog/scripts/composer/ScriptHandler.php:160
OK, so I double-checked the class inside my project's /vendor folder. This method is there. My IDE points me there. But when I run:
$fs = new Filesystem();
get_class_methods($fs);
this method is not listed.
Which file is it trying to load the method from?
OK, so I tried to check which file it's loading this class from:
$fs = new Filesystem();
$a = new \ReflectionClass($fs);
echo $a->getFileName();
and that returns me phar:///usr/local/Cellar/composer/1.7.2/bin/composer/vendor/symfony/filesystem/Filesystem.php – But why? Why is it taking the package from my Mac's Cellar? That's odd.
But OK, so I thought that's a Homebrew issue, and uninstalled the Homebrew Composer $ brew uninstall --force composer and installed it again as PHAR like documented on https://getcomposer.org/doc/00-intro.md#globally.
But now it's the same.
$fs = new Filesystem();
$a = new \ReflectionClass($fs);
echo $a->getFileName();
returns me phar:///usr/local/bin/composer/vendor/symfony/filesystem/Filesystem.php.
But why? Why does it pick up the (outdated) package from my global Composer installation? How can I force my script to use the project's local class and not the one from my global Composer installation?
What else?
Initially my $PATH contained /Users/leymannx/.composer/vendor/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin. I removed /Users/leymannx/.composer/vendor/bin to only return /usr/local/bin /usr/bin /bin /usr/sbin /sbin. Still the same.
I also tried setting the following in my composer.json. Still the same:
"optimize-autoloader": true,
"classmap-authoritative": true,
"vendor-dir": "vendor/",
I finally created an issue on GitHub: https://github.com/composer/composer/issues/7708
https://github.com/leymannx/wordpress-project/blob/master/composer.json
https://github.com/leymannx/wordpress-project/blob/master/scripts/composer/ScriptHandler.php
This is matter of context where your code is run. If you're executing some method directly in post-install-cmd it will be executed inside of Composer's process. It means that it will share all code bundled inside of composer.phar. Since you can't have two classes with the same FQN, you can't include another Symfony\Component\Filesystem\Filesystem in this context.
You can bypass this by running your script inside of separate process. You may create post-install-cmd.php file where you do all bootstrapping (like require vendor/autoload.php) and call these methods. Then run this file in your post-install-cmd hook:
"scripts": {
"post-install-cmd": [
"php post-install-cmd.php"
]
},
I did a Laravel 5.5.43 installation this morning with the following Composer command:
composer create-project laravel/laravel project-name
I then ran the following command in the project folder to install Laravel Collective:
composer require "laravelcollective/html":"^5.4.0"
I then added the following under providers in config/app.php:
Collective\Html\HtmlServiceProvider::class,
And I added the following under aliases in config/app.php:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
After that, I wanted to create custom form components, so I ran the following Artisan command:
php artisan make:provider FormServiceProvider
And in that new provider file, I added the following line to the boot method:
Form::component('customText', 'components.form.text', ['name', 'value' => null, 'attributes' => []]);
Lastly, I added the following to providers in config/app.php:
App\Providers\FormServiceProvider::class,
When I do that though and refresh the Laravel instance from the browser, I get the following error:
Class 'App\Providers\Form' not found
However, if I add the following at the top of the FormServiceProvider.php file, then it works:
use Collective\Html\FormFacade AS Form;
I understand the concept of namespaces and why that makes the Form::component method in the boot method in the file properly work, but what I don't get is why I need to add that use line to the file at all.
Isn't the 'Form' => Collective\Html\FormFacade::class, line in the aliases array in the app.php file supposed to do that for me so I don't need to add the use line to the FormServiceProvider.php at all? What am I missing / doing wrong / not understanding?
Thank you.
I probably should just delete this question, but the simple answer was to add the following at the top of the FormServiceProvider.php file:
use Form;
Thanks.
Run below command:
php artisan config:cache
php artisan cache:clear
I downloaded the yii2-jui in this link
yii2-jui
After that I put it under yiisoft folder
yiisoft\yii2-jui
when I run my application it gives me this error
PHP Fatal Error – yii\base\ErrorException
Class 'yii\jui\DatePicker' not found
How can I fixed this.where should I put the yii2-jui folder ?
Thank you in advance
I fixed the problem when I ran
sudo composer require --prefer-dist yiisoft/yii2-jui "*"
ONLY IN FOLDER basic, where are web, yii, models and etc.
Insert this in the view:
use yii\jui\DatePicker;
The best way is: run: php composer.phar require --prefer-dist yiisoft/yii2-jui "*" in your project
insert code:
'yiisoft/yii2-jui' =>
array (
'name' => 'yiisoft/yii2-jui',
'version' => '2.0.2',
'alias' =>
array (
'#yii/jui' => $vendorDir . '/yiisoft/yii2-jui',
),
),
in yiisoft/extensions.php file
Stop creating duplicate questions.
And you do not just download something and copy it in a folder. Use composer to install it. the Yii2 that you copied is just a shell, you have to use composer to install the rest of it. Composer does more then just copy the files it creates an autoloader that tells yii where everything is.
I am having some trouble configuring doctrine orm on windows 8, php 5.4. I have installed Doctrine using Composer.
I have followed the docs to the letter but when I run any commands, php vendor/bin/doctrine orm:schema-tool:create for example, my command line just outputs
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../doctrine/orm/bin"
BIN_TARGET="`pwd`/doctrine"
cd "$SRC_DIR"
"$BIN_TARGET" "$#"
I have also tried php vendor/bin/doctrine.php .... but it just prints out the above.
I have followed Doctrine's guide to the letter. Has anyone seen this before and if so, can you suggest anything?
i found a solution
there are also a bin folder in vendor/doctrine/orm/bin/ you can use this one like this
php vendor/doctrine/orm/bin/doctrine orm:schema-tool:create
make sure you have root folder and a cli-config.php file is present in root folder.
below is location where i found a solution
https://groups.google.com/forum/#!msg/doctrine-user/_ph183Kh-5o/_P_coljB-dcJ
this is working fine for me .
I had the same problem. The following solution worked for me:
"vendor/bin/doctrine.bat" orm:schema-tool:create
So, basically you:
use the ".bat" file provided by Doctrine and
enclose the call to that ".bat" file in quotes.
My Environment
Windows 7 Professional (x64)
PHP 5.5.12
Doctrine ORM 2.4.4
Do not write "php..." (it will write the file content)
Just "vendor\bin\doctrine orm:schema-tool:create" do the job (from the project root eg. c:\php\theProject).
Next, you will need a "cli-config.php" in the project root...
For Window version use backward slash "\"
vendor\bin\doctrine orm:schema-tool:create
not forward slash "/"
vendor/bin/doctrine orm:schema-tool:create
You can either install something like git bash or simply use the PHP version of the script:
php vendor\bin\doctrine.php orm:info
Obviously, the php binary directory should be in your PATH environment variable, otherwise, it's something like:
C:\path\to\php.exe vendor\bin\doctrine.php orm:info
Copy doctrine.bat (located at vendor/bin/doctrine.bat) to your project root directory
Create a bootstrap.php file in any path inside your project root directory with the following content:
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$paths = array("../model");
$isDevMode = false;
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => '',
'dbname' => 'angular_php',
);
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
Create a cli-config.php file in your project root directory with the following content:
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
// replace with file to your own project bootstrap
require_once 'path/to/file/bootstrap.php';
return ConsoleRunner::createHelperSet($entityManager);
Execute from a command line window (CMD):
c:\path\to\project\root\directory>doctrine --help
It's done!
I found it wasnt returning anything from the doctrine.php.bat. Turns out it was a PHP error in my cli-config.php file
Using Cygwin on Windows with doctrine installed via composer, was having the same problem
resolved by:
vendor/bin/doctrine.bat orm:convert-mapping
if you are still having issues you can run the cli script using php to get the console tools running:
for example
php cli-config.php orm:schema-tool:create
All the answers on this question are either outdated or outright incorrect. In my case, I observed, after installing the the library, the "\vendor\doctrine\orm\" folder was completely empty. The docs ask you to run vendor/bin/doctrine, which in turn attempts to call "vendor\doctrine\orm\bin\doctrine[.php]" (The php file extension is optional). After discovering this, I downloaded the library from the git repository and replaced the composer-installed version.
php vendor/doctrine/orm/bin/doctrine
then works fine.
Also, beware of the common misconception that the cli-config.php file must exist in the root of your project. It's fine to leave it in your config folder