AwsS3Adapter exception appearing locally but not in dev server - php

I'm working locally on a Laravel project, and suddenly started getting the following exception:
ErrorException in FilesystemManager.php line 193:
Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found (View: /Users/mypetproject/resources/views/layouts/topheader.blade.php) (View: /Users/mypetproject/resources/views/layouts/topheader.blade.php) (View: /Users/mypetproject/resources/views/layouts/topheader.blade.php)
A version of this is running on a server without any issue. Just to verify, I checked out the same branch, compared composer.json and composer.lock files and they are the same locally and on the server, did a composer update just in case, and it still fails locally but not in the server. The .env file is also the same.
FilesystemManager is in vender/laravel/framework/src/Illuminate/Filesystem and indeed attempts to use League\Flysystem\AwsS3v3\AwsS3Adapter as S3Adapter; however this is also the case with the version running on the server.
As a note, I'm not using S3 at all, and I don't really want to install league/flysystem-aws-s3-v3 since I'm not using it.
Any idea what could be wrong?
This is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.3.*",
"laravelcollective/html": "5.3.*",
"guzzlehttp/guzzle": "^6.2",
"google/cloud-storage": "1.1.5"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev",
"prefer-stable": true
}

I finally tracked it down to the autoload_static.php and autoload_classmap.php files in vendor/composer/
For some reason it was referencing an incorrect file (one previously using S3):
'App\\IsoClasses\\IsoStorage' => __DIR__ . '/../..' . '/app/IsoClasses/IsoStorageS3.php',
updated to
'App\\IsoClasses\\IsoStorage' => __DIR__ . '/../..' . '/app/IsoClasses/IsoStorage.php',
and it now works.
What is weird is that the dev server's files also have this, but it works in the dev server with no problems.

Related

why composer update causes laravel app to fail on redirects

I have a laravel app (version 5.5) that I have been developing for months.
For the longest time I could add new libraries in my composer.json file and run "composer update" so it would build a new composer.lock file and everything worked just fine. But now when ever I run composer update and I restart my laravel app, any thing I do which would cause the site to attempt a "redirect" (such as login or logout) produces the following error:
Type error: Argument 1 passed to Laravel\Lumen\Http\Redirector::__construct() must be an instance of Laravel\Lumen\Application, instance of Illuminate\Foundation\Application given, called in ... (depends on where I am doing a redirect)
so I am sure this must be caused by some package not properly updating. So if I simply delete the entire ..\vendor folder and then run composer install, it will fix the issue. Site will run fine for months then if I run composer update again the error comes back. So I know it is being caused by one of the packages being included. Does anyone know what to do to try to figure out what, or how or which package is causing this error?
In case you need it here is a copy of the composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"anhskohbo/no-captcha": "^2.3",
"askedio/laravel5-soft-cascade": "^5.5",
"aws/aws-sdk-php": "^3.25",
"aws/aws-sdk-php-laravel": "^3.1",
"doctrine/dbal": "^2.5",
"intervention/image": "^2.3",
"laravel/framework": "5.5.*",
"laravel/socialite": "^3.0",
"laravel/tinker": "~1.0",
"laravolt/avatar": "^1.8",
"league/flysystem-aws-s3-v3": "^1.0",
"pbmedia/laravel-ffmpeg": "^1.1",
"php-ffmpeg/php-ffmpeg": "^0.9.5",
"sammyk/laravel-facebook-sdk": "^3.5",
"braintree/braintree_php" : "3.27.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0",
"filp/whoops": "~2.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Http/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true
}
}
===============================================
Updated: To be clear I have searched my code for Laravel\Lumen and I find no references but when I search the \vendor folder I get several packages including Amazon AWS which does reference that (see below).... But how do I fix those packages?
Laravel\Lumen theres your answer. How come Lumen is being used?
Somewhere in your code you're importing the wrong class. The exception is stating that a Illuminate\Foundation\Application is being created, which is correct, but somewhere there is a type hint expecting Laravel\Lumen\Application. Do a search through your code for Laravel\Lumen\Application and you'll probably find the problem.

vendor class not found in laravel

I use unisharp file manager in my project. on my local machine everything works fine, but on remote server it throws error [Symfony\Component\Debug\Exception\FatalErrorException] Class 'Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider' not found
in config/app.php everything's correct
/*FileMananger*/
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
/*CKEditor*/
Unisharp\Ckeditor\ServiceProvider::class,
there is directory unisharp in vedor(so all files and directories are there). when i try to run composer install/update i get this error again. so everything in its right place, but laravel doesn't see this class.
comoser.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"maatwebsite/excel": "~2.1.0",
"appzcoder/crud-generator": "^1.2",
"laravelcollective/html": "^5.3",
"lavary/laravel-menu": "dev-master",
"nesbot/carbon": "^1.21",
"laracasts/flash": "^2.0",
"spatie/laravel-medialibrary": "^3.11",
"firebase/php-jwt": "^4.0",
"doctrine/dbal": "^2.5"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Http/helpers.php"
]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
Try to comment those lines in config/app.php and run composer require unisharp/laravel-filemanager again.
You can't set up service providers before they are downloaded through composer.
You need to run:
composer require unisharp/laravel-filemanager
Make sure your config/app.php unisharp providers is matched with the content in folder vendor unisharp composer.json
check below:
Config/app.php
vendor/unisharp-composer.json
the solution is very easy :)
just make sure you have this in your service provider:
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
not this one:
UniSharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,

Laravel 5.3 Uploading in ubuntu16.04 nginx with command composer install --no-dev

Everytime I run the command composer install --no-dev
I am getting this error, I am using maatwebsite in laravel as the error pointing out, I just don't know how to fix it.
PHP Fatal error: Uncaught
Symfony\Component\Debug\Exception\FatalThrowableError
: Class 'PHPExcel_Shared_Font' not found in
/var/www/laravel/config/excel.php:18
2 Stack trace:
0 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap
/LoadConfiguration.php(60): require()
1 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap
/LoadConfiguration.php(38):
Illuminate\Foundation\Bootstrap\LoadConfiguration->l
oadConfigurationFiles(Object(Illuminate\Foundation\Application),
Object(Illumina
te\Config\Repository))
2 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Applicati
on.php(203):
Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap(Object
(Illuminate\Foundation\Application))
3 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/K
ernel.php(268):
Illuminate\Foundation\Application->bootstrapWith(Array)
4 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/K
ernel.php(114): Illuminate\Foundation\Console\Kernel->boo in
/var/www/laravel/co
nfig/excel.php on line 182 Script php artisan optimize handling the
post-install-cmd event returned with er
ror code 255
Update:
This is the composer.json file content
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*",
"maatwebsite/excel": "~2.1.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
I would assume the reason you getting this error is because you're running --no-dev and you have maatwebsite/excel listed as a require-dev dependency.
You'll need to remove it as a dev dependency and then require it as a normal dependency and it should be fine.
Hope this helps!

Installation of package.json

i am unable to install this library from GitHub. [Minishlink/web-push]
I have Laravel 5 installed on my server, I want to install this in the Laravel directory (project). And will use the library via custom PHP.
I am facing below issues:
When I run composer require minishlink/web-push, I get below error:
When I run composer require mdanter/eec, I get below error
When I run composer require pargonie/rndom_compat, I get below error
Here is the composer.json file (I have not included the web-push file here as I am using the require command via putty, [Please correct me if I'm wrong])
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"guzzlehttp/guzzle": "~4.0",
"maatwebsite/excel": "~2.0.0",
"aloha/twilio": "^2.0",
"laravel/socialite": "2.0.*",
"ixudra/curl": "6.*",
"laracasts/utilities": "^2.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"laracasts/utilities": "~2.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
This is the same type of issue as #17. It's not related to Minishlink/web-push. One of your dependancies is stuck in the past with paragonie/random_compat v1.1.5. You should check which one and ask the owner to update the composer.json. To fix this temporarily, in your composer.json, on your dev machine put:
"paragonie/random_compat": "dev-master as 1.1.5",
"minishlink/web-push": "^1.1"

Fatal error: Class ... not found in ... /ProviderRepository.php on line 146

This sounds like a trivial mistake, but I've been unable to find the solution for hours.
I tried to use https://github.com/michaelbonds/laravel-db2 in my Laravel project, and I added it using composer.
Here's my composer.json.
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"michaelb/laravel-db2": "~2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
Here's the error:
PHP Fatal error: Class 'MichaelB\Database\DB2\DB2ServiceProvider' not found in /var/www/html/mysjsu/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
and
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'MichaelB\Database\DB2\DB2ServiceProvider' not found
I found a similar question before on StackOverflow, and somebody suggested that the order matters. So, here's what I did in the following order:
add "michaelb/laravel-db2": "~2.0" to composer.json
run php ../composer.phar update
add MichaelB\Database\DB2\DB2ServiceProvider::class to the providers arary in config/app.php
run php artisan migrate
Any idea on what might've been the problem?
This package is a fork of cooperl/laravel-db2. The documentation is inaccurate.
He changed the namespace to MichaelB but never tagged this as a stable version, so when you composer require his ~2.0, packagist gives you an older version with the wrong namespace.
So when you run composer update, it runs some post-cmd scripts such as php artisan optimize which tries to pull from the config file but fails because that class doesn't exist.
Here's how to fix it:
Change composer.json to this version:
"michaelb/laravel-db2": "dev-master"
Run composer update --no-scripts
Then you should be good.

Categories