I have a dedicated server with WHM and cPanel. It already has composer installed on it.
I'm trying to run the following php lines in a webpage:
require __DIR__ . '/../vendor/autoload.php';
// Configure API key authorization: JWT
$config = \Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Authorization', '[my api key]');
$apiInstance = new \Swagger\Client\Api\MessagesApi(
new \GuzzleHttp\Client(),
$config
);
I've created a composer.json in the public_html folder and put the following in it:
{
"autoload": {
"psr-4": { "Swagger\\Client\\" : "lib/" }
}
}
And then I ran composer update in the terminal which seemed to install the dependencies and all the relevant files.
It's seeing the autoload.php file but I'm still getting a class not found error:
Fatal error: Uncaught Error: Class 'Swagger\Client\Configuration' not found in /home/mywebsite/public_html/converter/sms.php:9 Stack trace: #0 {main} thrown in /home/mywebsite/public_html/converter/sms.php on line 9
I've been at this for 4 hours now. What am I doing wrong? I can't find anything online that will guide me in the right direction.
In Composer Basic Usage documentation about autoloading it says
For libraries that specify autoload information, Composer generates a vendor/autoload.php file. You can include this file and start using the classes that those libraries provide without any extra work
So, as #NicoHaase said in the comments, if you installed Swagger with Composer (adding a require key and running composer update, for example) you don't need to specify the autoload path to Swagger in composer.json.
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 !
I am trying to configure the bundle from : https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html
and when I try to run the command :
$ php bin/console doctrine:fixtures:load
getting error:
In LoadDataFixturesDoctrineCommand.php line 95:
Could not find any fixture services to load.
You need to update (app/config/services.yml)
services:
resource: '../../src/DataFixtures/*'
https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html
Other problem is here in to the above tutorial
// src/DataFixtures/AppFixtures.php
namespace App\DataFixtures;
name space should be :
namespace DataFixtures;
I am trying to install symfony2 JMS DI Extra bundle.
But i keep getting this error
Fatal error: Interface 'CG\Proxy\InterceptorLoaderInterface' not found
in
/home/xxxxx/public_html/XXXX/Symfony/vendor/bundles/JMS/AopBundle/Aop/InterceptorLoader.php
on line 30
I have found the solution here
https://github.com/schmittjoh/JMSAopBundle/issues/7
But could not able to understand where to fix the path
I think that's cg-library is missing. Open a command prompt into your Symfony vendor folder and issue:
git clone https://github.com/schmittjoh/cg-library.git cg-library
The add cg-library into your deps file:
[cg-library]
git=https://github.com/schmittjoh/cg-library.git
target=/cg-library
i am trying to install FOSRest & FOSRestBundle
initially , i have specified following settings in the deps
[FOSRest]
git=git://github.com/FriendsOfSymfony/FOSRest.git
target=fos/FOS/Rest
[FOSRestBundle]
git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
But that cause me into following error when i access http://localhost/Symfony/web/app_dev.php/
Fatal error: Declaration of
FOS\RestBundle\Routing\Loader\RestRouteLoader::setResolver() must be
compatible with that of
Symfony\Component\Config\Loader\LoaderInterface::setResolver() in
/home/logicase/public_html/Symfony/vendor/bundles/FOS/RestBundle/Routing/Loader/RestRouteLoader.php
on line 29
After that i tried following setting to make to the master branch and above error remains the same
[FOSRest]
git=git://github.com/FriendsOfSymfony/FOSRest.git
target=fos/FOS/Rest
version=origin/2.0
[FOSRestBundle]
git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
version=origin/2.0
and now when i run php ./bin/vendors install
i get following message in console.
Installing/Updating FOSRest 5eb800bd63ba84e5fc7028386cb66373bc3efafc fatal: ambiguous argument 'origin/2.0': unknown revision or path not
in the working tree. Use '--' to separate paths from revisions
Installing/Updating FOSRestBundle c11ab9d990a1e0e979b1c8ab72cc9793b4b2dcb5 fatal: ambiguous argument
'origin/2.0': unknown revision or path not in the working tree.
I tried following settings for FOSRest which solved my problem for symfony 2
[FOSRest]
git=git://github.com/FriendsOfSymfony/FOSRest.git
target=fos/FOS/Rest
version=origin/0.6
[FOSRestBundle]
git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
As you can see, there is no 2.0 branch : https://github.com/FriendsOfSymfony/FOSRestBundle/branches https://github.com/FriendsOfSymfony/FOSRest/branches The installation documentation does not talk about it. You should just remove the version lines.