Laravel 5 : emanuelzh/loptimizer installation - php

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!

Related

Symfony and doctrine issues

I did not use the sudo when installing doctrine in symfony
So this is what i got..
The "https://flex.symfony.com/aliases.json" file could not be downloaded: failed to open stream: Connection refused https://flex.symfony.com/aliases.json could not be fully loaded, package information was loaded from the local cache and may be out of date
to fix that i did this curl -XGET https://flex.symfony.com/aliases.json
and then i installed composer require symfony/orm-pack composer require --dev symfony/maker-bundle
The problem is that it wont add any db config in the env file....
and when i do the composer require doctrine
i get this
Pontuss-MacBook-Air:cauldron_overflow Pontus$ composer require doctrine
Using version ^1.0 for symfony/orm-pack
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.4.*"
Nothing to install or update
Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.
Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.
Generating autoload files
34 packages you are using are looking for funding.
Use thecomposer fundcommand to find out more!
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [OK]
Executing script assets:install public [OK]
Executing script security-checker security:check [OK]
So why wont it add the correct data to my env files?
Please any advice
When you install a recipe it installs some sample data to your .env.dist file.
This is only for the first run when you install the recipe. After the install you can do what you want and remove that variables and use it from your Docker for example. So perhaps i don't understood your problem because you wrote that you don't want db config in your env file and in the last line you write that it won't add it.
https://symfony.com/doc/current/configuration.html
I know you use flex but there are some good examples how to use and how to do it. Flex should use the DotEnv-Component.
The last thing is your error (https://flex.symfony.com/aliases.json). I think you have firewall that blocks the load of the aliases file. So you have to check that first. That call should work if you run it in your browser or with curl. Otherwise it could give a problem to load all components.
I solved the issue by removing doctrine and reinstall the package :) and now the env file looks like it should :)

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.

Setting up php-casperjs with composer

I'm having trouble setting up php-casperjs for my project. I've never used composer before, so I'm not exactly sure what I'm doing wrong.
I got xampp installed on Windows with php version 5.6.12
Here are the steps I completed so far.
Downloaded and installed composer. It launches successfully from the command prompt.
Downloaded php-casperjs and extracted composer.json and src/Casper.php into my project folder C:\xampp\htdocs\test
Navigated to the project folder in the command prompt and ran composer install command which installed 22 packages
Then I ran composer require phpcasperjs/phpcasperjs command and here I ran into problems. I get the following error message
Using version ^1.2 for phpcasperjs/phpcasperjs
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package phpcasperjs/phpcasperjs No version set (parsed as 1.0.0) is satisfiable by phpcasperjs/phpcasperjs[No version
set (parsed as 1.0.0)] but these conflict with your requirements or
minimum-stability.
Installation failed, reverting ./composer.json to its original
content.
When I run the following php code
use Browser\Casper;
$casper = new Casper();
I get Fatal error: Class 'Browser\Casper' not found in C:\xampp\htdocs\test\test.php on line 3
Step1: Go to you project directory and create a file "composer.json"
codes for composer.json
{
"require": {
"monolog/monolog": "1.0.*"
}
}
Note: You can create you composer.json with your required packages but i just created a simple composer.json file with monolog/monolog package. For your understanding you can follow my steps (this). You can remove the package monolog later on.
Now navigate to the project directory where composer.json file located
Run the following command:
composer require phpcasperjs/phpcasperjs
And you faced the above problem because of wrong or mismatched version of the intended package. Keep in mind that you always can create composer.json with your custom packages and their versions and which will be your package manager. For more detail about composer please visit Link

Laravel composer update error: Nothing to install or update

When I run composer update, I get the following error:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Illuminate\Foundation\ComposerScripts::postUpdate
php artisan optimize
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Laravel\Cashier\CashierServiceProvider' not found
Script php artisan optimize handling the post-update-cmd event returned with err
or code 255
I put this code on the app.php file
Laravel\Cashier\CashierServiceProvider::class,
and in the composer.json I also put this
"laravel/cashier": "~6.0"
like in the laravel doc
stack errot
Remove the
Laravel\Cashier\CashierServiceProvider::class,
from app.php.
It needs to be added after installing the package.
Also, instead of composer update, try composer require without changing the composer.json file.
composer require laravel/cashier
Don't add anything in composer.json file or app.php.
Just follow the documentation given in Laravel website for Laravel Cashier, (select the laravel version which you are using in your project).
Run the commands in following order:
//install the package and add it in composer file
composer require laravel/cashier
//add your cashier class in 'providers' array in app.php
Laravel\Cashier\CashierServiceProvider::class,
//add alias in 'aliases' array in app.php
'Cashier' => Laravel\Cashier\CashierServiceProvider::class,
//will add several columns to users table & create a new subscriptions table
php artisan migrate
Check the php version in cmd useing php -v
if php version is < 7.0 then install latest version of php.
Uninstall the old verion Xampp
Install latest version of Xampp to upgrade php.

class 'Former\FormerServiceProvider' not found - Laravel

i'm trying to install the anahkiasen/former package once again but it won't work. The funny thing is, I downloaded it about a weak ago and it was working perfectly. My code if finished and use's this former package. I tried to install a new package a half hour ago and since this the former class isn't found anymore.
Like I mentioned it, it was working perfectly before, but since I did a composer update it doesn't work.
Well I did what they said over here:
https://github.com/formers/former/wiki/Getting-started
first I run this::
composer require anahkiasen/former:4.0.*#dev
then a composer update
after the update I add this in my config/app.php provider section:
Former\FormerServiceProvider::class,
and this in the alias section:
'Former' => 'Former\Facades\Former',
I tried it but it still doesn't work. Just getting
Class 'Former\FormerServiceProvider' not found
as an output
I removed the package I wanted to install before and found another way.. But the problem with the former class is still there.
Thanks for any help!
Terminal outputs:
/var/www/laravel# php composer.phar require anahkiasen/former
gives:
Using version ^4.0 for anahkiasen/former
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
-------- then I added the provider/alias --- after this:
composer update --no-scripts
gives
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
composer dump-autoload
gives of course:
Generating autoload files
/var/www/laravel/logs# php artisan config:publish anahkiasen/former
gives:
PHP Fatal error: Class 'Former\FormerServiceProvider' not found in /var/www/laravel/logs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Former\FormerServiceProvider' not found
note that I changed the directory in the last command
Let's start from the beginning.
Follow below steps:-
1) Run below command in terminal:-
composer.phar require anahkiasen/former
2) It'll ask you for the version, type dev-master
3) Add Former's service provider to your Laravel application in app/config/app.php. In the providers array add :
'Former\FormerServiceProvider',
Add then alias Former's main class by adding its facade to the aliases array in the same file :
'Former' => 'Former\Facades\Former',
4) run composer update --no-scripts
After that, run composer dump-autoload, and that should work.
If not working then run this command:-
php artisan config:publish anahkiasen/former
Hope it will help you :)

Categories