Laravel blade variable default value issue - php

I have a blade master view in Laravel which contains the code {{$home or ''}}. My server is using PHP 7.1, Nginx. I migrated the code to another server with cPanel, just copied the whole contents and database and setup everything. The server to which I migrated the code runs Litespeed and Php 7.3. The same code works on server running nginx but not the newly migrated server. When I browse the page, I get Undefined variable: home. How can it run on nginx and not when using Litespeed. I'm new to litespeed and I haven't configured anything specific to laravel. Can someone please help to get this working.
Edit 1:
based on this, this syntax doesn't work on Laravel 5.7 and above but I'm using 5.8 and it works fine at the moment on old server.

Please try this
{{$home ?? ''}}

Related

Controller is not accessible in localhost

I have installed Codeigniter 4 (the latest version) using composer. Everything is ok, but I am not able to access the controllers.
When I hit http://localhost/myProject, it displays the Welcome page. But when I try to hit
http://localhost/myProject/public/index.php/myProject it displays a 404 error. I don't know the reason. Please help me I am using the XAMPP server on Windows 10 Machine with PHP version 8.1.
Consequently, I am not able to access any of my controllers.
Thank you!

cpanel is showing 500 internal server error even after chaning the php version of a laravel website

My project is on larvel 5.8 with a node_modules folder. My problem is that my hosting server is showing 500 error internal server error event after changing the version of php in my server.
In my website built using laravel 5.8 I have used admin lte 3.0.0 as an admin panel and it is working fine in artisan server and also with localhost with php version 7.2.
But when I copy all of my code including .extension files in the public_html folder and then when I try to go to the site it shows the internal server error.
I want at least show some error message on the screen so that I can debug the code.
Please enable the laravel debugger to show error on home page
2nd thing you might be missing you dependencies or hidden files if you found all file there then just run command on server "composer update"
If you changed the php version you need to configure laravel cache.
Use:
php artisan config:cache
2nd all of your composer packages are based on php & laravel version.
You should try "composer update" in a testing environment with same version on the live server to see if the packages are compatible.

Trying run working Laravel project on my PC via XAMPP

I have a whole project with database, everything is working here.
Project with database
I would like to run website so I can see changes I have made.
Im using XAMPP. My configs for VirtualHost hosts and http-vghosts.conf
I have tried this https://youtu.be/iXYCnYRalaw?t=2m13s ->> from [2:13] to [4:22]
using XAMPP, but still cant run it.
Can you give me any advice or steps how to make website run on my PC? [ofcourse just for me (VirtualHost)].
Editor using: Atom
My PC spec
If running laravel appliation inside XAMPP htdocs folder is really necessary, then could you provide some kind of error, simply telling "it doesn't work" doesn't help at all.
One thing you can try is to open command prompt inside laravel folder and run
php artisan serve
This will open local server that runs current project in:
http://127.0.0.1:8000
Also, checking laravel minimum requirements is something you should check out. 5.5 requires PHP 7 and you didnt tell what XAMPP version you are running.

Installed Laravel But Phpmyadmin has conflict with Laravel Routes

I Have installed Laravel on my Windows. So While accessing http://localhost:8000/phpmyadmin it doesn't seem to be working since it has some kind of conflict with laravel routes.
Sorry, the page you are looking for could not be found.
1/1NotFoundHttpException in RouteCollection.php line 161:
How can I fix this?
javad71
It would appear that your issue is this. When you run your server for you laravel installation, your system is looking at the /path/to/code/public folder. This folder in the Laravel installation does have an .htaccess file that does some 'magic' for laravel translating the url you visit into the correct route.
Thus, the configuration inside of the phpmyadmin setup is not getting hit when you visit /phpmyadmin from the browser at the root of your laravel project.
A couple suggestions here for this.
1: Change Laravel to not use port 8000 if you can typically run phpmyadmin from that domain. If you started laravel server by running the artisan command, the port can be changed by running php artisan serve --port 8888 where 8888 is any other open port.
2: In the PHP My Admin configuration, change the port number it listens on to something else.
-Brian
javed71.
Not sure what you are trying to accomplish but PHPMyadmin is supposed to be installed together with your Apache, PhP and MySQL if you're using XAMPP or WAMP. Visting http://localhost/phpmyadmin and resulting to 404 or PageNotFound error means that there is no running instance of Apache on your machine. However, laravel has a command for running its own service via php artisan serve.
If you are trying to just visit PhPMyAdmin, make sure you've installed XAMPP, WAMP or any stacked servers. Hope these help.

Laravel application displays only white page on live server

I have made an application using Laravel 4.2 . It works well on Wamp, But when I uploaded it onto a shared host, it only displayed a blank page. I followed all the advice given in the following links but it still isn't working.
Uploading Laravel Project onto Web Server
Avoid public folder of laravel and open directly the root in web server
I just realized that laravel 4.2 requires php 5.4 or greater, but my host uses php 5.3.28. Can this be the cause of the problem? if not, then what is the reason I get only blank page?
Yes - using Laravel without the required version of PHP will absolutely give you problems. You'll have to either upgrade your webserver or ask your host if it is possible for them to upgrade or enable a newer version of PHP for you.
Regrettably, when theres an error in PHP code there's only a blank page.
Try putting this in there
error_reporting(E_ALL);
Give permissions to storage folder. chmod -R 0777 app/storage
run command
php artisan key:generate
problem solved in my case

Categories