Laravel 5.2 - Artisan Optimize - Class 'TestMakeCommand' not found - php

I run my local environment on docker /w shared code volumes.
When my Dockerfile runs php artisan optimize it fails with...
Step 14/15 : RUN composer install && composer update
---> Running in 94698cafb7bf
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 0 installs, 2 updates, 0 removals
- Updating aws/aws-sdk-php (3.30.0 => 3.30.2): Downloading (100%)
- Updating barryvdh/laravel-ide-helper (v2.3.2 => v2.4.0): Downloading (100%)
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Illuminate\Foundation\Console\TestMakeCommand' not found
Script php artisan optimize handling the post-install-cmd event returned with error code 1
However, it I run locally php artisan optimize it works fine, and also if I remove that from composer.json it will build fine and I can run it on the container with no issues, I don't understand the difference why it wouldn't run when building the container?

Related

The command "composer require barryvdh/laravel-dompdf" always gets an error

I am trying to run this command: composer require barryvdh/laravel-dompdf
And I get this in my cmd:
Using version ^1.0 for barryvdh/laravel-dompdf
./composer.json has been updated
Running composer update barryvdh/laravel-dompdf
Loading composer repositories with package information
Updating dependencies
Lock file operations: 5 installs, 0 updates, 0 removals
- Locking barryvdh/laravel-dompdf (v1.0.0)
- Locking dompdf/dompdf (v1.2.2)
- Locking phenx/php-font-lib (0.5.4)
- Locking phenx/php-svg-lib (0.4.1)
- Locking sabberworm/php-css-parser (8.4.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals
- Installing sabberworm/php-css-parser (8.4.0): Extracting archive
- Installing phenx/php-svg-lib (0.4.1): Extracting archive
- Installing phenx/php-font-lib (0.5.4): Extracting archive
- Installing dompdf/dompdf (v1.2.2): Extracting archive
- Installing barryvdh/laravel-dompdf (v1.0.0): Extracting archive
3 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
Illuminate\Foundation\ComposerScripts::postAutoloadDump
#php artisan package:discover --ansi
In PackageManifest.php line 178:
The C:\xampp\htdocs\Proyectos\Monitor\bootstrap\cache directory must be present and writable.
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
And even on top of that, my project stopped working and shows:
This error that I've never seen before
I tried everything that I found on internet, clear cache, update composer and still I get the same kind of error, I am using Laravel 9 version. I'm desperate please help
Step 1 : Delete the cache folder and recreate again in bootstrap directory.
step 2 : run the command php artisan cache:clear

Composer crashes when it tries to Resolve dependencies

I am trying to use Composer to install dependancies inside a Docker container running PHP 5.6.40.
It runs, but quits and the vendor directory is always empty.
MacBook:my-app dev$ docker exec my-app_php56_1 php -d memory_limit=-1 composer.phar update -vvv --no-cache --no-plugins
Disabling cache usage
Running 1.9.0 (2019-08-02 20:55:32) with PHP 5.6.40 on Linux / 4.9.184-linuxkit
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/var/www/html): git branch --no-color --no-abbrev -v
Reading /root/.composer/composer.json
Loading config file /root/.composer/composer.json
Loading composer repositories with package information
Downloading https://repo.packagist.org/packages.json
Updating dependencies (including require-dev)
Downloading http://repo.packagist.org/p/provider-2013%24b962a943715f142bd3c36c0e87b67b28b16c014a98898622ec735220b7e1ee4f.json
Downloading http://repo.packagist.org/p/provider-2014%24ecc1513d9762efcfd48fdbaf4a08f829a59093064f40b7c351f93f3fbdd07973.json
Downloading http://repo.packagist.org/p/provider-2015%24258303eff7165b17439353fe44e501a3a6d600bd5b5482c5261a2ffa2234a947.json
Downloading http://repo.packagist.org/p/provider-2016%2496e2313b5ba90c2b798b03f9e306a27c15f11f763cd6478b834943fc128fc111.json
Downloading http://repo.packagist.org/p/provider-2017%24d2ad294ebaf381b7bf68cacbe514cf2bb33c3a919b97319bfa2e2ffaa66bc511.json
Downloading http://repo.packagist.org/p/provider-2018%2466893d07acdb18bb12d5e92e062b6e3058f5d284292b09cf585bf0ceb1b26aca.json
Downloading http://repo.packagist.org/p/provider-2018-10%24ff53e18093ae3e52a84c5567489c78bf1d82d0af80f413c3d6ad35d541a28434.json
Downloading http://repo.packagist.org/p/provider-2019-01%2431194ef7551ee4bffd7cc09dd6d01dc60848afc129544438ac7931e9d42dd54e.json
...
Downloading http://repo.packagist.org/p/phpspec/phpspec%248dc959bd0ae544f84e5bceee933d9a61d0a2074b208c3b7e7807cdc320e83eee.json
Downloading http://repo.packagist.org/p/phpspec/php-diff%249b8687b7c99f069823a9ac8d17900f9c8243368ceea9a5ac4e71ab424bb6f2d5.json
Downloading http://repo.packagist.org/p/squizlabs/php_codesniffer%24386b3726c6c3ce5edde180a7881f924be5dfd720c951dc93db8455ae871e9d61.json
MacBook:my-app dev$
It then just returns nothing and the vendor directory remains empty.
I am running composer without any plugins or cache.
Finally, the exact same composer.json file works fine in my other PHP 7.1.x container.
I also wondered if the final dependancies was causing an issue so tried removing it. Still no luck.
EDIT:
I've now gone back to my PHP 7.1 container and run the exact same scripts and it works fine. Composer's output is (so the 5.6 version just dies at the point that it does the "Resolving dependencies through SAT":
...
Downloading http://repo.packagist.org/p/webmozart/assert%24f23cf2d90bee4a1a09dc1d005896d60e715bdb9ecd4531874bfc3dd3ea5908c1.json
Downloading http://repo.packagist.org/p/phpspec/phpspec%248dc959bd0ae544f84e5bceee933d9a61d0a2074b208c3b7e7807cdc320e83eee.json
Downloading http://repo.packagist.org/p/phpspec/php-diff%249b8687b7c99f069823a9ac8d17900f9c8243368ceea9a5ac4e71ab424bb6f2d5.json
Downloading http://repo.packagist.org/p/squizlabs/php_codesniffer%24386b3726c6c3ce5edde180a7881f924be5dfd720c951dc93db8455ae871e9d61.json
Resolving dependencies through SAT
Looking at all rules.
Something\'s changed, looking at all rules again (pass #16)
Dependency resolution completed in 28.879 seconds
Analyzed 21713 packages to resolve dependencies
Analyzed 1376894 rules to resolve dependencies
Resolving dependencies through SAT
Looking at all rules.
Dependency resolution completed in 0.003 seconds
Package operations: 116 installs, 0 updates, 0 removals
Installs: kylekatarnls/update-helper:1.2.0, stripe/stripe-php:v2.3.0, abraham/twitteroauth:0.6.6, ralouphie/getallheaders:3.0.3, psr/http-message:1.0.1, guzzlehttp/psr7:1.6.1, guzzlehttp/promises:v1.3.1, guzzlehttp/guzzle:6.0.2, maknz/slack:1.7.0, maknz/slack-laravel:1.0.0, sabberworm/php-css-parser:8.1.0, phenx/php-svg-lib:v0.3.2, phenx/php-font-lib:0.5.1, dompdf/dompdf:v0.8.3, vlucas/phpdotenv:v1.1.1
...
etc for everything else
From the output of your run, it seems your composer setup is using http rather than https. Run this command before installing composer:
composer config -g repo.packagist composer https://packagist.org
This question is getting a little old now so I assume you already resolved it. I had the same problem recently.
The problem appears to stem from the change of PHP version. In my case I was going from 7.1 to 7.2, which you would imagine shouldn't cause too much of an issue.
My composer update -vvv --no-cache --no-plugins output would show
Resolving dependencies through SAT
Looking at all rules.
Something's changed, looking at all rules again (pass #[forever increasing])
After attempting to install symfony/thanks
In the end I had to remove symfony/thanks from my composer.json and run again. It then gave me some problems with a few other packages that I also removed. Once I had a successful run I was then able to start adding the offending packages back to my composer.json and eventually the issue was resolved.
I assume the underlying issue was a number of conflicts in the various levels of dependencies of my packages.
I guess if anyone finds they end up removing more and more packages, the solution would be to start from the minimum possible packages (the default Laravel composer.json in my case) and start adding new packages one-by-one.

Error when installing package with composer but package seems installed anyway

I'm trying to install the package maddhatter/laravel-fullcalendar (Laravel helper for FullCalendar.io) with composer.
So here is the command I run:
'''
php ../../composer.phar require maddhatter/laravel-fullcalendar
'''
And here is the result:
Using version ^1.3 for maddhatter/laravel-fullcalendar
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing maddhatter/laravel-fullcalendar (v1.3.0): Downloading (100%)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
php artisan clear-compiled
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\Foundation\Application::getCachedCompilePath()
Script php artisan clear-compiled handling the post-update-cmd event returned with error code 255
But now I wonder if the package is installed or not, because it now appears in my list of installed packages.
If anyone has the answer, thanks in advance.
Try to delete file compiled.php in your vendor directory manually, and then it started to work again.

Missing composer/zend command: development-enable

When I install Zend via composer create-project -n -sdev zendframework/skeleton-application as specified by Zend's main tutorial, I get a skeleton application that seems to work nicely.
However, when I follow this tutorial's advice to use composer development-enable, I get the following message:
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "development-enable" is not defined.
Is anyone able to duplicate/fix this problem?
I would normally assume it's an issue with the bash $PATH value, but the composer command by itself runs just fine, so I'm thinking it may be some other problem specific to this subcommand -- a missing dependency somewhere, for example.
Here is the relevant piece of the tutorial I am trying to follow:
https://docs.zendframework.com/tutorials/getting-started/skeleton-application/
(In case it helps for purposes of duplication: The CLI PHP version on my development server is 5.4.43. For reasons I won't bore you with, I can't update this CLI PHP to a newer version; the major release that Apache is using on my machine is 5.6.)
EDIT 1: Rerunning my installation using composer create-project -s dev zendframework/skeleton-application (as specified in the linked tutorial) still results in the same problem.
EDIT 2: Here is my shell input/output.
patrick [~/www/berlin-data]# composer create-project -n -sdev zendframework/skeleton-application
Installing zendframework/skeleton-application (2.3.3)
- Installing zendframework/skeleton-application (2.3.3)
Loading from cache
Created project in /home1/patrick/public_html/berlin-data/skeleton-application
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing zendframework/zendxml (1.0.2)
Loading from cache
- Installing zendframework/zendframework (2.3.3)
Loading from cache
zendframework/zendframework suggests installing doctrine/annotations (Doctrine Annotations >=1.0 for annotation features)
zendframework/zendframework suggests installing ircmaxell/random-lib (Fallback random byte generator for Zend\Math\Rand if OpenSSL/Mcrypt extensions are unavailable)
zendframework/zendframework suggests installing ocramius/proxy-manager (ProxyManager 0.5.* to handle lazy initialization of services)
zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf for creating PDF representations of barcodes)
zendframework/zendframework suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha for rendering ReCaptchas in Zend\Captcha and/or Zend\Form)
Writing lock file
Generating autoload files
patrick [~/www/berlin-data]# cd skeleton-application/
patrick [~/www/berlin-data/skeleton-application]# composer development-enable
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "development-enable" is not defined.
When you run the command
composer create-project -n -sdev zendframework/skeleton-application
This will create a directory in your current dir called skeleton-application inside of this directory is where you need to run the command:
composer development-enable
If this still doesnt work then something went wrong with install process.
The first command should give out put something like:
$ composer create-project -n -sdev zendframework/skeleton-application
Installing zendframework/skeleton-application (dev-master 941da45b407e4f09e264f0 00fb537928badb96ed)
- Installing zendframework/skeleton-application (dev-master master)
Cloning master from cache
Created project in C:\Users\<UserName>\Documents\skeleton-application
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
- Installing zendframework/zend-component-installer (0.3.0)
Downloading: 100%
- Installing zendframework/zend-stdlib (3.0.1)
Downloading: 100%
...
Notice this line Created project in C:\Users\<UserName>\Documents\skeleton-application
Thats the directory you need to be in to run the command:
cd C:\Users\<UserName>\Documents\skeleton-application
composer development-enable
If that still didnt work, try specifying the version for downloading:
composer create-project -n "zendframework/skeleton-application":"dev-master"
PS
As of writing this the skeleton application requires PHP "^5.6 || ^7.0". So if you are running a lower version composer wont install that copy. And the tutorials based on it may not work as expected.
Two things I've noticed: when you first initialize a skeleton application, depending on your settings, development mode is enabled by default.
If you want to run
composer development-enable
or any other similar commands, you must be in your path/to/install or path/to/yourapp directory for it to work! This is the folder that contains your local composer install. If you are in any of the parent directories, the command will not work.
I was also having this similar problem when trying to enable development mode with the command composer development-enable on my apigility app. I was getting error:
zf-development-mode is not recognised as an internal or external command.
There is a page on the apigility website regarding the development mode module:
https://apigility.org/documentation/modules/zf-development-mode
I found by following the instruction to install the module from composer:
$ composer require zfcampus/zf-development-mode
Then making a copy of the development config file:
$ cp vendor/zfcampus/zf-development-mode/development.config.php.dist config/
Now using the composer development-enable seems to work fine, which in my case returned the message 'Already in development mode'.

Laravel 5 : emanuelzh/loptimizer installation

I installed emanuelzh/loptimizer for Laravel 5 (on Ubuntu). It is a fork from https://github.com/approached/laravel-image-optimizer
It is for image optimization.
I successfully installed it with composer:
composer.phar require emanuelzh/loptimizer
Using version ^1.0 for emanuelzh/loptimizer ./composer.json has been
updated php artisan clear-compiled Loading composer repositories with
package information Updating dependencies (including require-dev)
- Installing emanuelzh/loptimizer (1.0.0) Downloading: 100% Writing lock file Generating autoload files php artisan optimize
Generating optimized class loader
But the problem is with config/app.php file. I added the following line but it doesn't work when I try to publish.
config/app.php:
Emanuelzh\Loptimizer\ServiceProvider::class,
Publish command:
php artisan vendor:publish
Result of publish command:
Nothing to publish for tag [].
Do you know what is the correct line to add in config/app.php ?
Thanks for your help.
Remy
Ok. Finally I found the answer :)
The line to add in config/app.php is:
Approached\LaravelImageOptimizer\ServiceProvider::class,
and for the facade:
'ImageOptimizer' => Approached\LaravelImageOptimizer\ImageOptimizer::class,
Hope it helps!

Categories