2

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.

caldicot
  • 195
  • 2
  • 15
  • check the file permission. – iamab.in Mar 24 '18 at 17:54
  • I checked the file permission. System, my user and Administrator have full access (I am also admin on this system). I also tried adding Everybody as user and give full permission. Still the same problem ... May I have set the permission not correct? – caldicot Mar 24 '18 at 18:14
  • when you try to access the url `http://localhost:8000/css/search.css` what error/response do you get in your console/network tab. – iamab.in Mar 24 '18 at 18:21
  • The browser brings http404 error page, saying `Not found: The requested resource /css/search.css was not found on this server.` In the console where I started the server the following message appears `[Sat Mar 24 19:24:04 2018] 127.0.0.1:59448 [404]: /css/search.css - No such file or directory`. And the chrome dev tools reports `Failed to load resource: the server responded with a status of 404 (Not Found)` – caldicot Mar 24 '18 at 18:24
  • test these - place any random file in the directory and try to access it? also move files to some other directory or sub directory and try to access it. – iamab.in Mar 24 '18 at 18:30
  • I created a `text.txt` file in the public folder. I was not able to access it. Same http 404 messages as before. Then, I moved into `css` folder - again not accessible. Even creating a new folder `test` and putting the `text.txt` in it does not help. Always getting http 404 – caldicot Mar 24 '18 at 18:36
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/167478/discussion-between-ab-in-and-caldicot). – iamab.in Mar 24 '18 at 18:38

0 Answers0