问题
I just decide to start learning Laravel. By following Getting Started most easy solution for me seems to be to start using laravel installer.
So what I did was installed installer globally and then simply created new project via laravel new laravelapi
.
After cli prepare it I edited .env
file with my database info and changed APP_URL
to http://localhost/laravelapi/ (I'm using XAMPP and laravelapi is name of my project). Unfortunately when I opened browser on that URL I just see the files, not a rendered website.
Funny thing is that when i open http://localhost/laravelapi/server.php
site load correctly (it's just some trivial laravel default page)
I was wondering if htaccess
works correctly I tried to check if my apache has mod_rewrite
as one of his loaded module but it was there.
I am really new in it and I obviously missed something important, but I fight here with it for couple hours without any result. Does anyone face this issue before? If so what was the solution?
回答1:
The Document Root for a Laravel project is the public
directory. All user requests should be routed to public/index.php
unless the file requested exists within the public
directory -- e.g: assets.
You can change the document root for an xampp operated project by following the steps provided in this StackOverflow answer.
回答2:
Its not good practice to access project through "http://localhost/laravelapi/public"
Probably you will face problems for symbolic links or while hosting your project. It's good to have vHost for your PHP projects.
You can create a vhost for xampp and add document root upto the public directory of your project for Laravel, like as "../Project/laravelapi/public".
Also you can use inbuilt development server command as php artisan serve
which will start your server on "http://localhost:8000".
More helpful links 1. Laravel Documentation - here 2. vHost for Xampp - Here
来源:https://stackoverflow.com/questions/49883869/creating-new-app-with-laravel-installer-shows-just-file-structure-not-website