why is Blade code getting rendered on the page? - php

I just started learning Laravel, Installed Laravel 7.6.2, and PHP 7.4.4
Without modifying a single line of code in the entire Laravel project, I try to open the welcome.blade.php, but it doesn't load correctly, the Blade code is displayed on the page as shown in this screenshot.
Can anyone help me know the reason for this problem and how to fix it?
The next screenshots include the welcome.blade.php code
1, 2, and 3

How are you accessing blade file ?
doesn't seem like you are accessing it via route
Steps:
open terminal/cmd
goto your project directory
run php artisan serve
Open browser and type in http://localhost:8000
After these steps you will see the welcome.blade.php rendered in your browser
Note:
You need xamp / wamp to get apache service on your localhost

The reason why blade is because .blade.php is the template engine for laravel thus enable it writing of notation # with if statement

Related

Why are all my routes displaying a 404 page?

I am working locally on a webpage in laravel with wamp, everything is going smoothly except that my routes are not working I have watched youtube videos and exactly followed their instructions
Route::get('/',function(){
return view ('client-side');
});
this is returning a 404 page
also I have tried returning a simple echo with this code
Route::get('/hello', function()
{
echo 'hello man'
});
And this also returns a 404 page, I dont understand why this isnt working, ty in advance
You said you were working locally with WAMP. But you were not specific about how you were trying to access your website. So, I am wondering if you need to add public to the end of your URL. See, Laravel reads from the public directory. If you are using WAMP, then most likely you haven't don't have it reading from public.
So, let me give you an example. If you are using myWebSite as your directory from your WAMP directory, if you haven't set your hosts files, etc., then you would need to access your website like this http://localhost/myWebSite/public. Make sense?
Another way of accessing your website would be to use the built in web server. From a terminal window in the root directory of your project, type php artisan serve in the terminal window. You should then get a message that says "Laravel development server started: http://127.0.0.1:8000" so then you should be able to access your website at http://127.0.0.1:8000
Probably your problem is in calling url.
Image that your project in htdocs.So you should call your page likethis:
localhost/{YourProjectFolderName}/public/{route}
If you want remove public from url you should cut its content and past it in previous path and edit index.php file.
If you want remove {YourProjectFolderName} from your url you should edit config of wampp.

Unable to load the PHP files other then index.php file from NetBeans

I am trying to run the other PHP files from my project folder that I am currently working on, I get this error while running it straight from NetBeans.
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
Otherwise, when I run the project from localhost it opens up the main page index.php perfectly.
Please advise on what I am missing.
The address that I am trying is:
http://localhost/evs/php342/project/process/process_signup.php
I hope your project structure looks like this
If you want to run process_signup.php as your default page while running the project from Netbeans you should configure the project.
In order to do that Right Click on your project and select Properties
Now select Run Configuration
In Index File text field select the process_signup.php file by using the Browse button right to the text field.
Now you're good to go. Right Click on your project and select Run. After that Netbeans will launch your default page.

Laravel shows blank page (continuously loading)

After having installed Laravel 5.1 on a local desktop, I installed it on a webserver (debian 8, php 5.6.17), set the directory permissions for storage and bootstrap/cache tp 1777. All worked fine. Next I installed it on another webserver, same method, same settings, but now it only shows a coninuously loading page. Tried a re-install, with the same result
Started manual debugging and the code falters in the index.php at $kernel->terminate(.... I also changed caching and session storage to redis, which made no difference.
Have been reading through the 'blank pages' posts, and been googling on it too, without any helpfull result so far.
If I let the script die before the '$kernel->terminate(...' line it shows the page else it just shows the page loading ... Unfortunately, pagination, and sorting a.o. do not work due to the premature ending of the script.
Anyone encountered this peculiar behaviour before
Cheers,
It happens most probably due to permission issue.Try this
chmod 777 -R storage/
Storage folder existed inside the Laravel folder.If nothing works, try to give full permission to Laravel Project folder and try again.
Problem caused by NFS filesystem. It doesn't allow file locking. Solved the problem by writing sessions to memcached
For me what fixed my issue was removing some laravel comment in my blade files. Especially comments of html code on multiple lines.
It took afew days to figure it out!! Very annoying.
{{--
html code here
--}}
see:
Blade Comments in Laravel are crashing apache
Laravel - Blade comments , blade rendering causing page to crash

Laravel 5.1 Pagination URL Error 404 Not Found

I am using Laravel 5.1 on WAMP Server 2.5.
And I have this error while working on pagination.
404 Not Found
While I run my site locally using this php artisan serve
php artisan serve --port=212
I run to my site index url http://localhost:212/displays.
The pagination works fine, its pagination link work fine on every page http://localhost:212/displays?page=2.
But when I run it manualy without php artisan serve (http://localhost/bookstore/public/displays), the pagination link goes wrong. The pagination link originally printout http://localhost/bookstore/public/displays/?page=2, but it automatically change into http://localhost/displays?page=2 when the page fully rendered.
Is anyone have same problem like me? Glad if any of you could help.
This is likely because you're meant to set the web root on your server to the public folder (and Laravel assumes that that's the case).
As it is, your web root is set to somewhere two levels above the public folder, so when Laravel tries to redirect to /displays?page=2 it tries to send you to the wrong folder.

Opening Yii Application causes download of index.php

I recently downloaded Yii in my linux-ubuntu system. After extracting the files to /var/www/vishnu/, I went for creating the first webapp.
What I have done is executing /var/www/vishnu/yii/framework/yiic webapp anyname in my command line. It succesfully created the application under /home/ti/anyname
But whenever I am trying to access it, It downloads the index.php file instead of opening the webapp home page! Why does this happen? I tried, the following Urls..
localhost/vishnu/anyname/ - Returns Not Found
home/ti/anyname/index.php- Downloads the file
home/ti/anyname/index-test.php- Downloads the file
I can see the files in file:///home/ti/anyname/ But can't open anything. When ever I click on it, it is being downloaded! Please share your solutions if you have any...
Thank you very much. I got it from this blog.
I changed the command such that, the webapp will point to my localhost itslef.
ie php /var/www/vishnu/yii/framework/yiic.php webapp /var/www/vishnu/yii/anyname/
Now its working... :)

Categories