7
Note that the instructions given here are made on the basis of Laravel 5.1, may or may not work in Laravel 4.2
The folder you have to access is the public
(I also got confused the first time I used the Laravel), this is a common problem among most people who use the first time Laravel.
Laravel in development environment
You have 3 options:
Use the server.php which is a script to run the php in stand-alone mode (apache-free), go to the terminal and go to your project folder in Laravel:
$ cd /home/user/projeto-em-laravel $ php -S localhost:8000 server.php
Configure Apache to point to the folder of
public
Laravel (has the possibility to configure a virtualhost as well)DocumentRoot "/home/user/projeto-em-laravel/public" <Directory "/home/user/projeto-em-laravel/public"> AllowOverride all </Directory>
Configure an . htaccess in the folder
./projeto-em-laravel
to point everything to the folder./projeto-em-laravel/public/
, create in folder./projeto-em-laravel
the file.htaccess
and put this content in it:<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^ /projeto-em-laravel/index.php [L] </IfModule>
If it is a production environment
In the case of a production environment nay use the server.php (although I think it would be almost impossible), with Apache you can try step 2 or 3 already mentioned, however if the server that will install the Laravel does not give you control over apache, then try to follow this:
Usually servers have a folder called
public_html
orwww
access through Cpanel (if applicable) in other cases the folder where you should play the files is the name of the site, for example./www.meusite.com
.In these cases you should try step 3 then you will play all the content (only the content) of the folder
projeto-em-laravel
in the briefcasepublic_html
for example and should create a file.htaccess
same as step 3, the folder structure should look like this:./public_html |--- .htaccess |--- /public |--- index.php |--- .htaccess |--- /app |--- /bootstrap |--- /config |--- /database
There are developers who simply play the contents of the folder
projeto-em-laravel
out of ofpublic_html
and inpublic_html
place the content of./projeto-em-laravel/public
, This is an option too, but you may end up getting lost with the existing folders of the server, it should look something like:/home/user/ |--- /access-logs (pasta padrão em servidores com cpanel) |--- /etc (pasta padrão em servidores com cpanel) |--- /public_ftp (pasta padrão em servidores com cpanel) |--- /tmp (pasta padrão em servidores com cpanel) |--- /public_html (pasta padrão em servidores com cpanel) |--- index.php (arquivo da pasta /public) |--- .htaccess (arquivo da pasta /public) |--- /app (pasta do seu projeto laravel) |--- /bootstrap (pasta do seu projeto laravel) |--- /config (pasta do seu projeto laravel) |--- /database (pasta do seu projeto laravel)
Setting up the Laravel
Before using Laravel you need to create the file
.env
, note that in the Laravel folder there is a file called.env.example
copy it and the name of.env
if it does not exist.Then you will need to configure the
APP_KEY
, it must be a 32 character key, for example:APP_KEY=2XXjEeJYr2jO0lboHZPHLuN6eYmnxPvl
I recommend you use the command
key:generate
to generate such key, note that to use the commandartesian
it is necessary to have configured by Poser and have added the environment variables, navigate to the folder of your project and then use the command:$ cd /home/user/laravel $ php artisan key:generate
When moving the project to production (pro server online) you must change the line
APP_DEBUG=true
forAPP_DEBUG=false
, this will turn off errors that should only be displayed for the development environment and not for the end user and also changeAPP_ENV=local
forAPP_ENV=production
.
O . env in Laravel in development environment:
APP_ENV=local
APP_DEBUG=true
APP_KEY=2XXjEeJYr2jO0lboHZPHLuN6eYmnxPvl
O . env in Laravel in production environment:
APP_ENV=production
APP_DEBUG=false
APP_KEY=2XXjEeJYr2jO0lboHZPHLuN6eYmnxPvl