Laravel app won't update database connection settings - php

I have a Laravel app, been using a specific set of database settings for a very long time, now I uploaded the whole application to CPanel and trying to change both the .env and .env.example files but still, when I look at the error logs uses the old database details, am stuck. Thanks in advance.

After cracking and scratching my head several times, I actually used these laravel CLI commands
php artisan config:clear
php artisan cache:clear
Now everything is working okay. Of course I took it offline first and used htdocs until it worked okay then uploaded the latest files.

I'm not sure if you are using the latest laravel framework 5.4 but you can try the following:
Clearing the config cache with this artisan command
php artisan config:clear
Checking the environment
php artisan env
With this command you can make sure that you are running under the correct environment. If you are using specific .env file such as ".env.local" or ".env.dev" etc.
Make sure there's nothing wrong with your dbms installation and try to connect to another blank db.
Hope this helps you!

Related

Changes in Laravel Blade view not reflected in webpage

I'm having a strange problem when updating a Blade view in a Laravel project hosted on a Linux CentOS server. The changes I make (deleting or commenting out a line of html) are not reflected on the webpage. I tried clearing the view cache with php artisan view:clear to no avail. When I go to /var/www/app/storage/framework/views and check the compiled php view the changes are there, but they still don't show up on the webpage. The old version of the view must still be stored somewhere, I just can't figure out where. Any help is much appreciated.
Edit: As an addendum, I also tried php artisan cache:clear as well as clearing the browser cache and neither worked.
Linux CentOS release 7.3.1611;
Apache 2.4.6;
PHP 7.1.7;
MySQL 5.5.52-MariaDB;
Laravel 5.3.31.
Run
php artian view:clear
OR for broad prospective, run
php artian optimize:clear // This is available for post Laravel 6 versions
If you are using chrome open dev tools, then settings and check disable cache
option
It works like a charm for me.

Laravel PHP run php artisan serve automatically if something changes

I am using laravel for a php webproject.
Yesterday I noticed an issue:
Everytime I make changes f.e. in the controller files I need to rerun php artisan serve, which consumes a lot of time (close CMD, open it again and type php artisan serve)
I am trying to find a way, so this command will automatically rerun when I test my application on localhost.
I could probably write a script or something with Python, which will automatically open CMD and execute php artisan serve whenever I click f.e. CTRL + F5, but that feels very hacky, is there a cleaner solution?
I also found a guide on how to edit the hosts file in system32 folder and the httpd-vhosts.conf in the apache folder, but after doing all steps, if I try to reach my application I get "It works" instead, which is simply an indicator for a successfull apache installation.
You should avoid php artisan serve cause it's just a shortcut to run your Laravel project. For a better development environment, you should use Laravel Homestead which offers a complete solution.

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 5.4 does not see changes in files

I'm using Laravel 5.4 on Windows 7 and Xampp 3.2.2. A few days ago Laravel started ignoring the changes I was making to the .env file. I couldn't find the solution so I reinstalled Laravel in a different directory and imported my app folder.
Now Laravel just stopped responding to the changes I am making to some PHP files. I added a function to the /vendor/illuminate/support/helpers.php but I could not access it in the view. I deleted the content of the whole file and I could still access the function previously declared in it.
I created a helpers file as instructed here but that too is being ignored.
Any changes to any views is immediately effected and php artisan cache:clear is not doing anything.
How is this happening? Does it even make sense?
Laravel caches config values to improve performance.
You need to run either (recommended)
php artisan config:cache
which will cache the new values you have, or
php artisan config:clear
which will turn off caching. I've had some experience with this causing errors though.
I know it might sound rather stupid, but have you remembered to restart the server because you've edited the .env file?

php artisan up command not working in laravel?

I have this very strange problem in laravel. I successfully put my website into maintenance mode via artisan by this command:
php artisan down
But now i have to put my website back into live mode.I tried:
php artisan up
However, the site isn't going live even though i get success message? Have you guys ever faced this issue?
Whats the fix?
I'm on :
1. Macbook pro Mamp
2. Laravel 5.1
Thanks
artisan up command simply deletes storage/framework/down file. Please check if the file exits after you execute the up command. If it still exists, it seems like a file access issue. Whenever you run down/up commands, make sure that you run them as the same user that is running your application.
In order to get the site up and running again, remove the storage/framework/down file manually.

Categories