Blank white screen problem is common in laravel. In this section, we are going to discuss some reasons behind the problem. This screen appears after uploading project in the shared hosting normally. There may be variety of reasons behind this problem. We will discuss some common reasons over here.
Incorrect File/Directory Permission
Incorrect permissions might result blank white screen problem with 500 server error in the console. We can set general permission of laravel project like this:
// Directory Permission
sudo find /path/to/your/laravel/root/directory -type f -exec chmod 664 {} \;
// File Permission
sudo find /path/to/your/laravel/root/directory -type d -exec chmod 755 {} \;
// .env permission
sudo chmod /path/to/your/laravel/root/directory 777 .env
// storage and bootstrap permissions
sudo chmod -R 777 /path/to/your/laravel/root/directory/bootstrap
sudo chmod -R 777 /path/to/your/laravel/root/directory/storage
These are commonly used permissions for laravel project files and directories.
Incorrect Version of PHP
Incorrect php version is most common reason behind blank screen problem. In order to fix this, we can use MultiPHP Manager. You can see this in cpanel main menu.
In this way, we can select correct PHP version for our laravel project.
Also Read: How to change user password in laravel ?
Configuration Cache
Sometime Configuration cache can cause such problem because laravel uses cache for getting configuration data. If you have ssh access to the server then you can execute following command in terminal.
php artisan config:cache
If you don't have ssh access, don't worry mate since you can programmatically execute artisan commands. Just add following code to web.php and hit the url in browser.
Route::get('/cache', function(){
$exitCode = \Illuminate\Support\Facades\Artisan::call('config:cache');
});
This command will clear the cache and creates the new one for the project. You have to hit the url: appurl/cache.
Programmatically Executing Commands
This is official laravel documentation for programmatically executing artisan commands.
Middleware
We can use middle ware for variety of reason. Blank screen can appear if we forget to write following code in handle function.
return $next($request);
When we assign middle ware to route, the handle function will be executed to check whether it passes middle ware.
View Cache
Laravel also uses view caches since it loads views from the cache. If blank white screen appears even after above steps, we have to clear view cache. We can clear view cache with following command in terminal if we have ssh access.
php artisan view:clear
If you don't have ssh access then, you can execute it programmatically like this:
Route::get('/cache', function(){
$exitCode = \Illuminate\Support\Facades\Artisan::call('view:clear');
});
Conclusion
In this section, we have discussed about variety of reasons behind the blank white screen problem. Most common reason among these reason is incorrect php version. Other reasons are also responsible for such problem.
Leave your Feedback