I am developing a small web app using Laravel 5.6. I recently upgraded Laravel to 5.6 and therefore also updated PHP to version 7.2.3 as php7.1 is a requirement for Laravel.
I am developing on a Windows 10 machine.
For testing I am using the php built-in webserver.
I either use the Laravel shortcut to start the server php artisan serve
or I call directly the php -S localhost:8000 -t public
command, the result is the same.
Since I updated php, I am not able to access any asset (css, js) through the browser.
blade file:
<head>
<meta charset="UTF-8">
<title>My Site</title>
<link href="{{ asset('css/search.css') }}" rel='stylesheet'>
</head>
Output in Chrome:
<head>
<meta charset="UTF-8">
<title>My Site</title>
<link href="http://localhost:8000/css/search.css" rel='stylesheet'>
</head>
Folder structure of the laravel project is:
- Root of Laravel Project
- public
- css
- search.css
I can't access the search.css
file by entering http://localhost:8000/css/search.css
, the server logs 127.0.0.1:52980 [404]: /css/search.css - No such file or directory
The file is in the right place, and the generated urls are also correct. In fact I didn't change anything and with older php version it worked. But of coursed I double checked a dozent times.
Validating the path in my controller.php
with a few lines of code:
public function index(Request $request)
{
$t3 = public_path("css\\search.css");
var_dump($t3);
var_dump(file_exists($t3));
}
And the result was:
string(91) "C:\Users\me\Documents\LaravelProject\public\css\search.css" bool(true)
Deploying the application to a AWS EB environment will work. So my guess, that there is a problem with the built-in webserver.
Can anybody imagine, what is wrong? The small webserver is of course very handy during development.