Laravel 4 Artisan not working at all - php

Just playing with Laravel 4 for the first time after using version 3 for a few projects but can't seem to get Artisan to work at all. I've done a bunch of searching and followed the troubleshooting steps I could find but no luck.
I've got Mcrypt installed
I had no bootstrap/compiled.php file to delete
I have the latest version of the framework from Github
I am on the latest version of Composer
When I try "composer update" I get this error:
Script php artisan optimize handling the post-update-cmd event returned with an error:
...with no extra information.
Trying to run "php artisan list" or any other artisan command just gives me no output at all.
Any ideas?

To summarise the discussion in the comments, we discovered that adding logging at the php.ini level revealed a PHP error that was not reported by the Composer console interface. I wonder whether you had installed Composer as root, and so some critical files required by Laravel were effectively invisible for a non-privileged user.

After running phpinfo, I noticed "--disable-mbregex" was part of the PHP configuration, meaning PHP was not compiled with the mbregex extension. My error logs were showing "Call to undefined function mb_regex_encoding".
Once PHP was recompiled with mb_regex_encoding, the issue went away.

If you are missing the /bootstrap/start.php file, you don't get helpful error messages from artisan and composer responds the same way. I went around and around trying solutions I found online and ultimately discovered this file was missing. I was back online as soon as I replaced it. I discovered this file was missing in my PHP error logs and artisan wasn't generating logs since it was unable to run.

I had a similar problem. Even the command $ php artisan --verson would not produce any output. Turned out, I had some code under app/start/global.php which was breaking under the CLI execution (but not breaking on the web side).
So that's another place to check for stuff! (app/start/global.php)

I was getting this problem, and it was because the subdirectories of storage did not yet exist.
Of course, these directories are created by the project-creating script, but they're quite easy to leave out of source control and so will be missing on a freshly cloned project. The .gitignore files are in there for a reason it would seem!

This problem occurred for me when there were files in the storage folder that were not writable for the current user. php artisan silently failed, without output. Changing permissions helped.

Related

How do I get the "php artisan cache: clear" command to work?

I'm using a Mac. Can not execute the command
php artisan cache:clear
I get in return:
Failed to clear cache. Make sure you have the proper permissions.
This is for Laravel. Any ideas how to fix this?
create storage/framework/cache/data directory manually.
This could be one of several things(need more information to narrow it down):
No cache files/records exist.(Updated to reflect your latest comments)
If you are running a webserver (apache or ngix) as a different user, then you won't have permissions to the files as yourself.
If you are using a cache driver other than file, like redis or database, make sure the credentials provided are correct.
There could be a bug in the version of Laravel you are using; this would be unlikely.
Expansion on points 1 and 2:
This is normal behavior. If you have opened pages expecting them to be cached and they are not, split the page and utilize #include directives splitting out the dynamic and static elements of the page into separate blade files.
I like to add my user to the same group as the web server's group(www). Then change the group for all of the files to www, with group read permissions, and write permissions only on the bootstrap/cache and storage directories.
I think it might possibly be a bug with the latest version of Laravel, however unlikely it may seem. I started a new project today and installed a fresh copy of Laravel 5.7 and it seems to cause the error above. However, if I use 5.6 then the error does not appear.

Deploying Laravel 5.4 to Shared Hosting

I've got a real head-scratcher for you! I've been working on a Laravel 5.4 application for quite some time now and up until yesterday I had been able to:
develop on my local machine [still works flawlessly],
push my changes to my BitBucket repo [still okay here],
and would subsequently pull those changes to my shared hosting server (RedHat) [still running smoothly],
I then run my dependency managers (npm and composer) to get the project in place and functional
there is some matter with clearing various caches:
php artisan view:clear
php artisan route:clear
php artisan cache:clear
composer dump-autoload
and finally move my '/public' folder to the web root and update index.php to point back to the 'bootstrap/autoload.php' in main project structure,
I am aware there is likely another or several steps I am missing, but I am unsure what they are...
All that being said, I've attempted to deploy a number of applications using Laravel lately and I always seem to run into the same issue come time to deploy an application to production. I've read 30+ tutorials on the matter and nothing seems to explain the issue why my site isn't working any more.
I've checked the error log file maintained by Apache, it's empty.
Was wondering if it's a permissions issue, doesn't seem to be the case (all folders set to 775 and files set to 664 as specified by various sources and owned by serverName:userName)
Browser console simply shows a 500 server error.
All I see if "Whoops, looks like something went wrong." twice.
There must be some way to show better error details (config debug setting already set to true)
Any suggestions at this point would be beneficial to send me looking in the right direction!
======= UPDATES =======
For the sake of thoroughness, and that this save others from severe headaches, I'll be posting actions taken here.
Following tutorial mentioned by #user123456 (permissions applies)
Generate new key for application
Run php artisan config:clear
Off to the races, answer to come!
You need to ensure you have a working .env file.
Once done, run php artisan key:generate to create a key for your application after which you should clear your application's cache as follows php artisan config:clear
I would never recommend using shared hosting for Laravel application. You will face lots of issues for permissions, composer and external dependencies. Instead, you can use cloud servers like DigitalOcean, Linode, vultr and deploy laravel application on them. If you don't know about linux and creating Stacks you can use Cloudways to deploy laravel.
https://dev.to/rizwan_saquib/deploy-laravel-application-on-cloud-easily-with-cloudways

Laravel: Cannot generate migration file with make:migration command

I've got an ongoing project and migrations were working fine. But I don't know if something has changed, now php artisan make:migration my_migration_name is not generating a migration file and not showing any errors as well.
I've tried running it with -v verbosity flag but nothing is printed on terminal. My directory permissions seem to be fine;
I've also tried running it with sudo but I got this error message;
I've updated composer and tried to remove laravel and reinstall laravel/framework '5.1'. But nothing seem to help.:(
If someone has faced this kind of issue and managed to resolve it, help would be really appreciated. Any suggestion how to resolve this issue?
I've got it working somehow. It was really weird behavior and tried different solutions to get it working. I thought I should list down steps I follow to get it working, for someone who may get into this type of behavior.
Short and quick solution might be to clear all your cached data and application configs.
php artisan cache:clear # clear all cached files.
php artisan config:clear # clear application config cache
composer dump-autoload # reload all autoload classes
And quit the "TERMINAL" and reopen it, hope it should be working now.
If it still don't work then try following options and repeat above mentioned part;
Re-install your laravel/framework using composer. I found it while searching for solution
Check your directory permissions, see if you have write permissions.
Hope! It may help someone.

php artisan optimize times out only on composer install

I'm running a laravel app on Azure. Things are moving in the right direction, composer install didn't use to work at all. Now however, the "php artisan optimize" command times out:
However, running "php artisan optimize" separately is no problem at all:
What could be the cause of this?
Edit:
Deleting the symfony-folder does not help, it is not present when I run the "Composer install"-command:
Increasing the timeout-limit does not help either, I increased it in both azure and in the composer.json file:
This still gives me a timeout, after installing the symfony-components again:
...
As I deployed a new clean Laravel 5 application to Azure Web apps and tried to reproduce your issue, however, it worked fine on my side either I run the command php artisan optimize or composer install or composer update.
I installed the composer at the Site extensions at the KUDU console site of the application on Azure Web apps, the url should be like: https://<your_site_name>.scm.azurewebsites.net/SiteExtensions/#gallery
There are several solutions of other developers who occur the same issue with you, you can try these solutions:
try to increase the max_execution_time or set the value to 0, refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-php-configure/#how-to-change-the-built-in-php-configurations to change the PHP build-in configurations on Azure Web Apps. And you can change the process-timeout in Composer.json file :
"config" : {
"process-timeout": 0
}
deleted the entire Symfony folder and try again. As the comments at PHP Artisan Optimize - Timed out? #1050, it seems the symfony dependencies raise the issue.
#Rkey,
According to my experience, I think the issue is more related to the symphony version/configuration. I suggest you can remove/edit the symphony configuration from the composer.lock file (NOTE: please backup this file if you cannot success, you also can recovery your environment). And then you can run this "composer install".
After installed component, You can see an alert window which shows that
your session is timeout, please refresh your browser.
You can see this information because the server is in initialization process.
Any concerns, please feel free to let me know.
I'm also having this problem. Will upgrading the plan help?
According to this upgrading to S3 helps... I haven't tried it though... Let me know if it really works.
#Rkey & #cabs, per my understanding on this question, I wanna point out that Composer is not fully supported on Azure. The issue is that it’s using Taskkill command which is blocked on Azure. We are aware of this and please feel free to submit an idea or suggestion based on the experience with Azure at https://feedback.azure.com/forums/34192--general-feedback.
I have been stuck in this problem as well for a week.
Have tried all solutions on forum but no success.
This morning finally solved after reinstall XAMPP. It was problem on my previous PHP version 5.6.19. While using new XAMPP with PHP version 5.6.28, it worked fine.

Laravel 4 development server crashing without notice

I am developing an application in Laravel 4 using the built-in development server with a SQLite database. After a recent merge from another user in the project repository, the server will crash after certain requests.
I believe I have narrowed it down to a call of Sentry - when it is used on a request the server will crash out and the command line will exit.
$ php artisan serve
Laravel development server started on http://localhost:8000
Dwight at Dwights-MacBook-Pro.local ~/Sites/tmtbl on master*
$
As you can see, there are no error notices.
I've run composer update and ensured that Sentry is still installed correctly. I'm not sure whether this issue is Sentry specific or something else is going on. Is there something I am missing here that is causing the server to crash?
Do you use Chrome? If yes, go to the console and if you have an error, is it the same as: Failed to load resource when using Auth? Because I have the same problem with the php 5.4 server
You can use the Google Chrome browser to see the errors in the console.
Process
First run: php artisan config:cache
Second run: php artisan serve
Finally: go to your localhost and inspect your page, and then go to the console in the upper tab, you might be able to see the error.
Image of console:
Moreover, you can try:
composer dump-autoload

Categories