Php artisan optimize is failing on production server - laravel

Running composer install on a production server via a bash script is failing at post-install-cmd php artisan optimize with the error There are no commands defined in the "jwt" namespace.
To try to resolve the issue I added the following commands before php artisan optimize
"php artisan clear-compiled",
"php artisan cache:clear",
"php artisan config:clear",
"php artisan config:cache",
Running composer install locally works fine. I can run the commands through a script locally without a problem.
The failure is happening while running composer install through a script on the production server. If I log onto the server and run the commands manually I do not generate the error.
Not sure how to debug, any ideas?

Try adding a pre-install event inside of your composer.json file on the server, note that this event works only if your composer.lock is present and you ran composer install:
"scripts": {
"pre-install-cmd": [
"php artisan config:clear"
],
...
}

Related

Laravel, Breeze is not generating "Build" folder

Folder image
Even though I have done the following commands,
"php artisan breeze:install
php artisan migrate
npm install
npm run dev"
the build folder is not generating.

Running composer install not working with Jenkins in a microservices architecture

I am automating a microservices architecture with a Jenkins pipeline and having this issue although the file composer.json exists in that folder
C:\Program Files
(x86)\Jenkins\workspace\C2Project\C2\autority-service>composer update
Composer could not find a composer.json file in C:\Program Files (x86)\Jenkins\workspace\C2Project\C2\autority-service
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
here is the concerned jenkins stage:
stage('Build autority-service'){ steps { dir('C:\\Program Files (x86)\\Jenkins\\workspace\\C2Project\\C2\\autority-service') {
bat "sudo composer update"
bat "sudo composer dump-autoload"
bat "sudo composer install"
sh "php artisan key:generate"
bat "php artisan cache:clear"
bat "php artisan config:clear"
bat "php artisan migrate"
bat "php artisan db:seed" } } }
Can anyone please help me fix this issue?
I resolved this issue by adding a composer.phar file because Jenkins couldn't recognize the composer.json file as they are similar with this command line curl -sS getcomposer.org/installer | php then installed composer on the Jenkins server using the composer.phar file php composer.phar install

laravel telescope nothing to migrate

i have a laravel 6 app that i want to install the telescope in that i did all the commands like composer update and composer dump-autoload and then i install the telescope every thing is going fine and when i run php artisan telescope:install i get the message below :
Publishing Telescope Service Provider...
Publishing Telescope Assets...
Publishing Telescope Configuration...
Telescope scaffolding installed successfully.
but it wont generate the config file and migration so when i run php artisan migrate i get this message :
nothing to migrate
in your command
php artisan vendor:publish --tag=telescope-migrations
then edit you your env file
TELESCOPE_ENABLED=true
after this run
php artisan optimize
Finally
php artisan migrate
You must publish it first using the below command:
php artisan vendor:publish --tag=telescope-migrations
Then you will get the default migrations and also the config/telescope.php file
After installing the telescope in my project and exporting the default migration I got this error.
λ php artisan vendor:publish --tag=telescope-migrations
Unable to locate publishable resources.
Publishing complete.
How I solve this issue
If you're getting this issue open telescope.php file which is inside of your config directory.
and then set the value of this TELESCOPE_ENABLED to true
'enabled' => env('TELESCOPE_ENABLED', true),
Because in my case the value of TELESCOPE_ENABLED this was false
Then again run this command php artisan vendor:publish --tag=telescope-migrations.
I hope it will work :)
I had accidentally ran php artisan optimize in my local environment which was causing this issue. To fix it, I had to run php artisan optimize:clear, then uninstall laravel/telescope, remove any references to it, and install it again from scratch. It then recognised the migrations and the published assets.
I did this
composer remove laravel/telescope
Then change your .env file
TELESCOPE_ENABLED=true
Then install back again it worked!

There is no existing directory at /storage/logs and its not buildable: Permission denied

I have a problem with my Laravel deployment on a OVH web server.
After made
composer update
php artisan cache:clear
php artisan route:clear
php artisan dump-autoload
I have this answer:
There is no existing directory at /storage/logs and its not buildable: Permission denied
I put all the files on 777 chmod but I have always this answer.
Please try the following commands
php artisan route:clear
php artisan config:clear
php artisan cache:clear
Note: In case you are a Homestead & VirtualBox user, please be sure that your VirtualBox is up to date.
It helped in this thread at laracasts
Clear the cache and config, then deploy to the live server.
If you've already uploaded to the live server, then you have to follow these steps:
Delete bootstrap/cache/config.php
Delete all log files in storage/logs.
You don't need to add any permission on the storage file.
The main problem here is in the compiled file, and due to which laravel try to show an error.
By default in laravel, storage file not having permission to show in the console (error
shows from the error.log file).
So the thing you need to fix is to fix compile file. which can be done thought this single command
Use this
php artisan optimize:clear
This command will clear all your cache
Compiled views
Application cache
Route cache
Configuration cache
After changing local conf i got the same error over and over,
try this, probably will help.
rm bootstrap/cache/config.php
and then
php artisan cache:clear
depending on your scenario, reloading auto-loader file can solve your issue, for that use :
composer dump-autoload
or sometimes just try :
composer install
this do the two the commands listed above.
go to your vagrant
then run
vagrant ssh
php artisan config:cache
Run the following command if you can access your server terminal
php artisan route:clear && php artisan cache:clear && php artisan config:clear && php artisan config:cache
If you are on shared hosting and cant access the terminal go to your web route file in routes/web.php and make a temporary link such as shown:
Route::get('reset', function (){
Artisan::call('route:clear');
Artisan::call('cache:clear');
Artisan::call('config:clear');
Artisan::call('config:cache');
});
Then go to http://your-domain/reset to execute the commands. there after you can now access your website as normal
If you are using homestead (vagrant) in Laravel then follow the steps #Farid shahidi provided
vagrant ssh
cd /home/vagrant/code <-- your file usually resides here; see your Homestead.yaml configuration
php artisan config:cache
You Have to try artisan command in this way
php artisan cache: clear
php artisan config:cache
php artisan cache: clear
This one-line command solves my issue:
php artisan config:cache
Delete bootstrap/cache/config.php from your laravel deployment on the server.
Please run the below commands:
php artisan route:clear
php artisan config:clear
php artisan cache:clear
This one worked for me in case your project is located within /var/www/html/
sudo chmod -Rf 0777 /var/www/html/{project-name}/bootstrap/cache
sudo chmod -Rf 0777 /var/www/html/{project-name}/storage
You need to run this command from the terminal.
php artisan config:clear
php artisan config:cache
I got the same issue, I change the permissions of the folders inside the the storage folder.
chmod 777 <folder_name>
I'm not sure about this security wise. but this resolve my problem.
I change my file settings to 755 also work for me.
try this
remove your "vendor" folder
Run "composer install" or "composer install --ignore-platform-reqs" on your cmd or terminal
php artisan config:cache
php artisan config:clear
php artisan cache:clear
php artisan route:cache
php artisan view:clear
php artisan config:cache
if you are using linux:
service apache2 restart (just in case)
if you using xammp:
just restart your xammp
For those of you using sail, do:
sail artisan optimize:clear

Error while running again php artisan session:table command in Laravel 5.2

I am beginner to Laravel, when i run the command "php artisan session:table" first time it successfully created the session migration but unfortunately i have deleted this file. Now when running again this command "php artisan session:table"
its getting error.
error
Please tell me where laravel stores that information that session migration is already created.
Regards,
Kamal
Delete CreateSessionsTable migration in this folder
database/migrations
Run
composer dump-autoload
Then you can run
php artisan session:table
again.

Resources