The composer install command gives illegal offset type error - laravel

When I run the composer install command on my laravel project, I get this error:
> #php artisan package:discover --ansi
ErrorException : Illegal offset type
at /var/www/routes/web.php:57
56| $blah = app('config')->get('app.api_content_type_map');
> 57| $bb = $blah[$lang];
Exception trace:
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError()
/var/www/routes/web.php:57
2 Illuminate\Routing\RouteFileRegistrar::{closure}()
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:414
Please use the argument -v to see more details.
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
I have this in my config/app.php
'api_content_type_map' => [
'en'=>[
'news'=>'article',
'page'=>'page'
],
'fr'=>[
'nouvelles'=>'article',
'page'=>'page'
]
],
What did I do wrong?
UPDATE 1
This is the output of my php -v
PHP 7.4.2 (cli) (built: Jan 23 2020 11:21:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies
UPDATE 2
I deleted line 57, php artisan config:clear, add back the line,composer install, and still get the same error message. I went to another computer, did a fresh checkout of the project, tried to runcomposer install`, also the same error. So I'm thinking it's not actually some cache issue?

Related

laravel old version is not supporting php 8.0.8

I have installed php 8.0.8 on my local computer. Laravel new projects work perfect. But when I try to run Old projects it shows me error. When I try to run command
composer install
It gives me the error below:
Problem 1
- jeremy-dunn/php-fedex-api-wrapper is locked to version 5.0.1 and an update of this package was not requested.
- jeremy-dunn/php-fedex-api-wrapper 5.0.1 requires ext-soap * -> it is missing from your system. Install or enable PHP's soap extension.
To enable extensions, verify that they are enabled in your .ini files:
- C:\xampp\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
When I run:
composer dump-autoload
It shows this error:
Generating optimized autoload files Class App\Http\Controllers\Vendor\OrderController
located in C:/Users/Muhammad Adnan/Downloads/test-upwork-master/spree-retail/app\Http\Controllers\temp\OrderController.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Http\Resources\profile\AddressesResponse located in C:/Users/Muhammad Adnan/Downloads/test-upwork-master/spree-retail/app\Http\Resources\Profile\AddressesResponse.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Foundation\ComposerScripts is not autoloadable, can not call post-autoload-dump script
> #php artisan package:discover --ansi
Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php:14
Stack trace:
#0 C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\artisan(20): require_once()
#1 {main}
thrown in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php on line 14
PHP Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php:14
Stack trace:
#0 C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\artisan(20): require_once()
#1 {main}
thrown in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php on line 14
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
Unfortunately, older versions of Laravel doesn't not support newer versions of PHP. Laravel 6 is the minimal version for PHP 8.0 support (and it is already pretty old from a web development perspective).
Of course, this is for a fresh installation, you might have code in your project that is also not PHP 8.0 compatible.
About this error:
Problem 1
- jeremy-dunn/php-fedex-api-wrapper is locked to version 5.0.1 and an update of this package was not requested.
- jeremy-dunn/php-fedex-api-wrapper 5.0.1 requires ext-soap * -> it is missing from your system. Install or enable PHP's soap extension.
The problem will be easy to fix, just install the soap extension. You seem on Windows so it should already installed but disabled.
You will have to uncomment ;extension=soap.dll in your php.ini file (or maybe in the ext directory located in your php directory, it depends).
There will probably be other extensions required but disabled, to get a full list execute composer check.
This is what is preventing composer from installing your dependencies (which lead Uncaught Error: Class "Illuminate\Foundation\Application" not found in to when you are calling composer dump-autoload).
I searched out and found a solution regarding this issue. Only single command is the solution
Note: Don't update composer.
composer install --ignore-platform-reqs

How to remove ckeditor package (error: Class 'Ckeditor\CkeditorServiceProvider' not found)?

I followed the steps mentioned here:
How to remove a package from Laravel using composer?
including the step: Remove Service Provider from "app/config/app.php" (reference in "providers" array)
However, since I got an error:
In ProviderRepository.php line 208:
Class 'Ckeditor\CkeditorServiceProvider' not found
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1
The app is down and I cannot do any operation in terminal. How to get rid of the reference to this class?
Then run these commands.
php artisan cache:clear
composer dump-autoload -o
If an error occurs while clearing cache, then delete cache files under bootstrap/cache manually.

How to install Laravel v5.2.15 when I have already installed v5.6.12?

I am trying to install a lower version of laravel when I have already installed a higher version in my htdocs. But it throws an error.
C:\xampp\htdocs\laravel-6>composer create-project laravel/laravel=5.2.15 s6
Installing laravel/laravel (v5.2.15)
- Installing laravel/laravel (v5.2.15): Loading from cache
Created project in s6
> php -r "copy('.env.example', '.env');"
> php artisan clear-compiled
PHP Warning: require(C:\xampp\htdocs\laravel-6\s6\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\laravel-6\s6\bootstrap\autoload.php on line 17
PHP Stack trace:
PHP 1. {main}() C:\xampp\htdocs\laravel-6\s6\artisan:0
PHP 2. require() C:\xampp\htdocs\laravel-6\s6\artisan:16
PHP Fatal error: require(): Failed opening required 'C:\xampp\htdocs\laravel-6\s6\bootstrap/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\laravel-6\s6\bootstrap\autoload.php on line 17
PHP Stack trace:
PHP 1. {main}() C:\xampp\htdocs\laravel-6\s6\artisan:0
PHP 2. require() C:\xampp\htdocs\laravel-6\s6\artisan:16
Warning: require(C:\xampp\htdocs\laravel-6\s6\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\laravel-6\s6\bootstrap\autoload.php on line 17
Call Stack:
0.0007 344912 1. {main}() C:\xampp\htdocs\laravel-6\s6\artisan:0
0.0016 346488 2. require('C:\xampp\htdocs\laravel-6\s6\bootstrap\autoload.php') C:\xampp\htdocs\laravel-6\s6\artisan:16
Fatal error: require(): Failed opening required 'C:\xampp\htdocs\laravel-6\s6\bootstrap/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\laravel-6\s6\bootstrap\autoload.php on line 17
Call Stack:
0.0007 344912 1. {main}() C:\xampp\htdocs\laravel-6\s6\artisan:0
0.0016 346488 2. require('C:\xampp\htdocs\laravel-6\s6\bootstrap\autoload.php') C:\xampp\htdocs\laravel-6\s6\artisan:16
Script php artisan clear-compiled handling the pre-update-cmd event returned with error code 255
But when I tried installing laravel v5.6.12, it gets installed easily again. Please tell me a way around to install a lower version of laravel while keeping the higher version. Thanks.
Errors:Updates suggested by a member
I was suggested to download laravel's particular version manually and I did also tried to update composer but still facing problem. The error that has occurred is shown below:
Have you tried using this command to install a clean copy of laravel 5.2.15?
composer create-project --prefer-dist laravel/laravel laravelProjectFolder "5.2.15"

voyager - (Symfony\Component\Console\Exception\CommandNotFoundException] There are no commands defined in the "voyager" namespace)

So I am trying to install Voyager for my laravel, but when I insert
php artisan voyager:install
I am getting this error message:
(Symfony\Component\Console\Exception\CommandNotFoundException] There
are no commands defined in the "voyager" namespace)
Here is my PhP and Laravel version:
Laravel Framework version 5.3.16
λ php -v PHP 7.0.13 (cli) (built: Nov 8 2016 13:45:28) ( ZTS )
Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright
(c) 1998-2016 Zend Technologies
And my package service providers:
/*
* Package Service Providers...
*/
TCG\Voyager\VoyagerServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
So what is the problem? why am I getting this error message
Looks like you didn't install it. Comment out or remove service providers from the list and run these commands:
composer require tcg/voyager
composer dumpauto
According to the docs, next step will be adding a service provider to the config/app.php:
TCG\Voyager\VoyagerServiceProvider::class,
And only then run php artisan voyager:install command.
php artisan config:clear
solved my problem
If you have successfully executed the command line:
composer require tcg/voyager
You must have the line "tcg/voyager": "^1.2" in the require section of your composer.json file, in this case the command line "composer dumpautoload" will automatically perform all the packages discovery for you. Otherwise do the following :
add the line of code: TCG\Voyager\VoyagerServiceProvider::class to the file "config/app.php". Then run the following command line :
composer dumpautoload

Composer: The requested package php could not be found

Every time i try and run composer install, the dependencies fail due to the following error:
The requested package php could not be found
I've got this working on a LAMP stack, but I'm trying to get it working on a LEMP stack now, with php5-fpm and its not going well.
$ php -v
PHP 5.5.8-3+sury.org~precise+2 (cli) (built: Jan 29 2014 13:23:55)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
EDIT
I have other stuff in mine, but i tested the following composer.json on the same server, and its still doing it.
composer.json
{
"require": {
"php": "5.4.*"
}
}
my composer version is
Composer version b7a9ea4187bce63f418bf7ba035b63dcb1e23ef6 2014-02-06 22:07:47
Am I missing something?
Well, that's easy: Composer is exactly doing what you tell it to do.
You are requesting any version of PHP 5.4. You explicitly do not allow any versions of 5.5. So Composer correctly complains about having not the right version of PHP (yours is PHP 5.5, you request 5.4.*).
It is very unlikely that your code does not run with the newer version, so it's best to use this composer.json content:
{
"require": {
"php": ">=5.4"
}
}
Requesting a version greater than or equal 5.4 will also include 5.5 and above.

Resources