Creating new app with laravel/installer shows just file structure not website

五迷三道 提交于 2019-12-13 03:04:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!