Way\Generators is breaking Laravel Envoyer - php

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'
))
);

Related

Illuminate\Contracts\Container\BindingResolutionException - Target class [CommandMakeCommand] does not exist

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 !

composer auth.json not working / ignoring auth.json

i use the new feature of gitlab the composer package registry.
It works fine but the authentication with the auth.json file dont work.
I done all steps in the documentation of gitlab and composer but no success.
I tried to store the auth.json file beside the composer.json file and at %APPDATA%/Composer but it makes no different. I get allways the same error message.
https://docs.gitlab.com/ee/user/packages/composer_repository/
https://getcomposer.org/doc/articles/http-basic-authentication.md
If i use the inline authentication in the composer.json file at the repository object it works.
{"repositories": [{"type": "composer", "url": "https://extremely:secret#repo.example.org"}]}
I get following error message:
C:\path\to\project> composer update -vvv
Reading ./composer.json
Loading config file ./composer.json
Loading config file C:\path\to\project/auth.json
Reading C:\path\to\project/auth.json
Checked CA file C:\Users\user\AppData\Local\Temp\opeD84C.tmp: valid
Executing command (C:\path\to\project\ida.argo.data): git branch --no-color --no-abbrev -v
Reading C:/Users/user/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/user/AppData/Roaming/Composer/composer.json
Running 1.10.10 (2020-08-03 11:35:19) with PHP 7.4.8 on Windows NT / 10.0
Loading composer repositories with package information
Downloading https://gitlab.com/api/v4/group/8835906/-/packages/composer/packages.json
[Composer\Downloader\TransportException]
The "https://gitlab.com/api/v4/group/8835906/-/packages/composer/packages.json" file could not be downloaded (HTTP/
1.1 404 Not Found)
Exception trace:
() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Util/RemoteFilesystem.php:441
Composer\Util\RemoteFilesystem->get() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Util/RemoteFilesystem.php:105
Composer\Util\RemoteFilesystem->getContents() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ComposerRepository.php:695
Composer\Repository\ComposerRepository->fetchFile() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ComposerRepository.php:506
Composer\Repository\ComposerRepository->loadRootServerFile() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ComposerRepository.php:285
Composer\Repository\ComposerRepository->hasProviders() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Pool.php:108
Composer\DependencyResolver\Pool->addRepository() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer.php:393
Composer\Installer->doInstall() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer.php:232
Composer\Installer->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Command/UpdateCommand.php:163
Composer\Command\UpdateCommand->execute() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Command/Command.php:245
Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:835
Symfony\Component\Console\Application->doRunCommand() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:185
Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:281
Composer\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:113
Composer\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/bin/composer:61
require() at C:\ProgramData\ComposerSetup\bin\composer.phar:24
I hope someone can help me :) thx!
Gitlab updated his documentation.
https://docs.gitlab.com/ee/user/packages/composer_repository/index.html
You must use the gitlab-token configuration in the auth.json.
{
"gitlab-token": {
"gitlab.com": "<personal_access_token>"
}
}
To elaborate on Arth's answer and for people ending up here who followed the Gitlab directions, but use a different port for a (local) gitlab server: add the port to the different configs.
composer.json
"config": {
"gitlab-domains": [
"<your gitlab domain>:<custom port>"
]
},
auth.json
{
"gitlab-token": {
"<your gitlab domain>:<custom port>": "<personal_access_token>"
}
}
That got it working for me.
Try to edit:
/home/{USER}/.config/composer/auth.json file

I'am getting an error --- In ProviderRepository.php line 208: Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found

I'am new to laravel, and this is my first question because I could not find a solution anywhere.
I implemented JWT-token somehow and it worked until I mess it up. Now when I type php artisan serve I get that error, or when I try to publish. I tried everything like in question --- Laravel 5.6.26 Error- Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found --- but it won't work.
When I add in composer.json "tymon/jwt-auth": "^0.5.12" I get an error class LaravelServiceProvider not found, and when I change it to "tymon/jwt-auth": "^1.0.0-beta.3" or "tymon/jwt-auth": "^1.0.0-rc.2" then I ger error JWTAuthServiceProvider not found. I also tried composer require illuminate/auth but it won't work. Can I get some help please.
I had this same issue and I solved it by executing these commands
composer require illuminate/auth
composer require tymon/jwt-auth:"^1.0.0-rc.2"
composer update
Then
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"
You can safely remove from your app.php file
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class
You need to also add the alias to config/app.php like so:
'providers' => [
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
],
'aliases' = [
....
//other aliases
...
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuthFacades\JWTFactory::class`
]
and then include it at the top of the PHP file you want to use it in, like
use JWTAuth;
Try to delete config.php file from bootstrap/cache folder, it worked with me

Changing vendor directory can't find files anymore using Symfony 3.4

I'm trying to change the directory of my dependencies on a Symfony 3.4 application.
I need that because I'm working on macOS with Docker and I'd rather have them not shared with the host since the file synchronization is too slow.
The related documentation, says:
The change in the composer.json will look like this:
{
"config": {
"bin-dir": "bin",
"vendor-dir": "/some/dir/vendor"
},
}
That I did
Then, update the path to the autoload.php file in app/autoload.php:
// app/autoload.php
// ...
$loader = require '/some/dir/vendor/autoload.php';
I don't have any autoload.php file in my app directory.
Am I missing something in the doc ?
The application generates the following fatal error:
Warning: require(/some/dir/vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php): failed to open stream: No such file or directory in /vendor/composer/autoload_real.php on line 66
Fatal error: require(): Failed opening required '/some/dir/vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php' (include_path='.:/usr/local/lib/php') in /vendor/composer/autoload_real.php on line 66
I originally created the application with:
$ composer create-project symfony/framework-standard-edition test "3.*"
Open your composer.json file in editor.
Look for "autoload-dev" section
Remove whole "files" part (if exist)
Save file
Run composer install once again
Enjoy the party.
Sample code:
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
},
"files": [
"vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
In Symfony 3.4, the file app/autoload.php is removed so you should:
replace old vendor path by the new vendor path directly in web/app.php, web/app_dev.php, bin/console and var/SymfonyRequirements.php files
Rerun the command $ composer install
I had the same issue and it was resolved doing the next.
Follow these 3 steps
1. First of all, modify composer.json to use the new vendor path:
"config": {
...,
"vendor-dir": "/app-vendor"
},
And remove the next line:
"files": ["vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"]
2. Secondly, if you are using docker-compose add a new volume where you'll put your vendors.
volumes:
...
- /app-vendor
PD: /app-vendor is a mounted volume which is now empty directory.
3. Lastly, write require '/app-vendor/autoload.php'; to:
my_project_name/bin/console
my_project_name/web/app.php
my_project_name/web/app_dev.php
PD1: Simply, this line is pointing to the new vendor path.
PD2: It's not necessary to modify any other file (like var/SymfonyRequirements.php as I could read).
Check your changes
Once the changes are ready, remove vendor/ and also remove the containers to avoid future problems.
Start your new containers and execute composer install. Now, /vendor will be /app-vendor, it won't be in the root folder of the project anymore.
For more details, I'd recommend you to go to my docker-symfony repository and check the commits. You'll see a benchmark progression and another tips like cached volumes and non-shared /cache && /logs folders.
All for Symfony 3.4.

Laravel 5.2 - Will not recognise SimpleSMS new class provider / alias

I'm trying to install https://github.com/laggards/simple-sms to my laravel 5.2 project
Within require of my composer.json I have:
"guzzlehttp/guzzle": "~6.0",
"laggards/simple-sms": "~2"
In config/app.php under providers I have:
Laggards\SMS\SMSServiceProvider::class
Under aliases I have:
'SMS' => Laggards\SMS\Facades\SMS::class
At the top of my controller I have:
use SMS;
Within the controller:
SMS::send('This is my message', [], function($sms) {
$sms->to('+44123456789');
});
Error received:
Class 'SMS' not found
I have run the following to no success:
composer update
composer dump-autoload -o
composer dump-autoload
I would appreciate any help on this :)
Try this
Add Laggards\SMS\SMSServiceProvider::class in your config/app.php configuration file within the providers array.
Then Add 'SMS' => Laggards\SMS\Facades\SMS::class in your config/app.php configuration file within the aliases array.
After this run this command- composer dump-autoload
I followed this documentation and its working for me.
https://github.com/laggards/simple-sms
Problem seems to be that the documentation is wrong if you use the ~2 version the namespace is actually SimpleSoftwareIO instead of Laggards. So either use the dev-master version so it is Laggards or change the namespace to SimpleSoftwareIO. I'm not familiar with the package so not sure what the differences are.
You can see the correct documentation for ~2 version here.
Try
use \SMS;
or
use Laggards\SMS\Facades\SMS;

Categories