Laravel: Composer update when dependency is not yet installed - laravel

I require a dependency on my local environment. I add it's service provider and all is fine. The composer.json has this script
"pre-update-cmd": [
"php artisan clear-compiled"
],
When I push the changes to production, I try to run composer update but because of that script artisan fails with an error since the dependency is not yet installed and therefore the service provider I added in config/app.php is not there yet.
What is the best approach to situations like this? Just remove the pre-update script?

Hmmm interesting problem
What are you typing in for the service provider in your app.php
Have you tried removing your service provider and then running composer update and re-adding it after the dependencies have installed?

Interesting problem,
Please check your json file with
composer validate from your working directory.

Related

DigitOcean - laravel 8 deployment through Github (error 500)

I deployed the laravel app to digitalocean:
but I don't understand why is it showing error 500??
I connected a github repo to deploy it to digitalocean.
1- I set the build commands to: composer install
2- environment variables are set: APP_NAME, APP_URL, APP_KEY, DATABASE_URL, APP_DEBUG
This is how the repo looks (private)
What seems to be the issue??
I just did check the repo and it seems the vendors folder not there and your build steps look like a typo issue so please run below command
composer install
Still you face the issue then refer the laravel logs for that what went wrong
you also dont have a .env file
maybe copy the .env.example to .env
perhaps follow the instructions on the laravel site for the version you are using.
in your question, you have spelt 'install' incorrectly
turns out there were typos of lower and upper cases in controllers according to the laravel log.
I fixed them and now the site is running. It's weird that these typos didn't trigger erorrs locally..
All You have to do is configure the .env file if u have a .example.env edit the file to .env if u dont have it just try to create one or clone one from another project and do composer install but don't forget to generate a key with php artisan key:generate in the end

Laravel shows Symfony-styled exception even when APP_DEBUG set to false

Just deployed a new app to production and seeing a strange bug:
One of the pages has a PHP error and throws an exception. Strangely, it's a Symfony branded exception page (screenshot), different from the ones I've seen in Laravel before. Env file is already set to production environment and has APP_DEBUG=false.
Does anyone know how to fix this?
I've tried the following to clear & reset cache, but it didn't help
php artisan config:cache
Not sure if it matters, but the app was deployed using http://deployer.org with Deployer's Laravel recipe
The mostly likely reason for this is that when deployer runs composer install, it does so with the --no-dev option, which prevents the required packages from being installed. If you want to include dev packages upon deployment, add the following to deploy.php:
set('composer_options', '--verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader');
This is the default composer_options value with --no-dev removed.
There are also slightly more complex options that include having different tasks for different hosts, which is detailed here: PHPDeployer: set variable for local task based on host?

jwt.php not visible in config folder of laravel 5.4

I have successfully configured and make everything work perfectly. But i have an issue, i want to change the time to live but in my project "jwt.php" does not appear in the config folder.
If anyone knows the solution kindly guide me; help will be appreciated.
Many Thanks!
This is probably because you haven't published vendor files.
You should run:
php artisan config:publish tymon/jwt-auth
assuming you use https://github.com/tymondesigns/jwt-auth package to publish configuration file so you will have jwt.php created and then you can update config according to your needs
To publish vendor files, for Laravel 5.5, run
php artisan vendor:publish --tag=config

Laravel: There are no commands defined in the "ab" namespace

I have to publish a database in my laravel 4 app from another package. So I ran this command:
php artisan ab:install
It says
[InvalidArgumentException] There are no
commands defined in the "ab" namespace.
I tried running composer dump-autoload and also tried php artisan optimize.
Composer still throws the InvalidArgumentException.
EDIT
I had missed adding the service provider and registering the alias in the app.php file. Doing so fixed this issue.
I had missed adding the service provider and registering the alias in the app.php file. Doing so fixed this issue.
I had to add 'Jenssegers\AB\TesterServiceProvider', and 'AB => 'Jenssegers\AB\Facades\AB',
to the app/config/app.php
This fixed the issue.
Try to update composer with json file. Add the following code in json
"jenssegers/ab": "1.*"
Then save . Open command prompt. run composer update

Laravel 5 package installation

I want to install a laravel package but don't have any idea how to do it.
It is the Admin Architect package that I want to install.
http://docs.adminarchitect.com/Getting_Started
This is the getting started page, if you scroll down to Zip archive (Public way) you will see the installation.
They say that you have to extract it in the package directory. But I do not have a package directory in my laravel 5.1 project.
Does someone know if you have to make one and put all the files that I have in there?
You need to start at the Via Zip archive (Public way) section.
The way to do this is completely up to you. The best way is probably to create a packages folder in your main Laravel directory along with app, bootstrap, database directories etc...
Unzip the contents of the zip package and then add the required item to your repositories in your composer.json
"repositories": [
...
{
"type": "git",
"url": "./packages/administrator"
}
...
]
This will add the repository which contains the package terranet/administrator as long as the url is correct. You might have to modify it to get it to work correctly so that when you run composer require terranet/administrator, it will be able to actually find terranet/administrator from the repository.
From there, simply follow the rest of the instructions (adding the service provider, etc...).
The reason other answers are not working is because the package terranet/administrator is not available publicly and you need to add the repository to your composer.json file for that to become availble. You can see all packages available publicly by going to packagist.org where you will see searching for this package yields some results but not the one you are looking for.
I don't know if you missed the instruction on the documentation:
Open your terminal:
cd yourproject
then run:
composer require terranet/administrator
Add service provider in config/app.php file.
'providers' => [
...
Terranet\Administrator\ServiceProvider::class
]
Run this command to publish assets:
php artisan vendor:publish
OR
php artisan vendor:publish --provider=Terranet\\Administrator\\ServiceProvider to publish only administrator's files.
Optionally to create new administrator user run:
php artisan administrator:create
Finally open config/administrator.php and make settings
If you have composer installed you could run the following from your program directory:
composer require terranet/administrator
After the package installed, add a new service provider to the providers array in config/app.php file.
'providers' => [
...
Terranet\Administrator\ServiceProvider::class
]
Then, publish package's assets by running:
php artisan vendor:publish
OR
php artisan vendor:publish --provider=Terranet\\Administrator\\ServiceProvider
to publish only administrator's files.
Optionally you can run
php artisan administrator:create
to create new administrator user ->All this taken from the link you provided.
Update
The problem with minimum stability can be fixed using this link for reference:
Tell composer you want to use stable whenever possible:
"minimum-stability": "dev",
"prefer-stable" : true
This basically means it will always use stable UNLESS there is no way to install a stable dependency, and therefore use dev.

Resources