Blog

Run a Laravel project without Artisan Command

Image

This article will show you how to run Laravel without php artisan serve command.

You always need to run php artisan serve to run the Laravel project in command prompt. But you can rid of this process and can run the project directly though your local server.

Let me show you how

Step #1

First, find the “server.php” file in root of your root directory. Copy and paste in on root directory of your project and rename it from “server.php” to “index.php”.

Step #2

Copy the ".htaccess" file to the public directory and paste the project directory as root.

<IfModule mod_rewrite.c>
    RewriteEngine On
    #added for api
    RewriteEngine On
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
    #end

    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^$1 [N]

    RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
    RewriteRule ^(.*)$ public/$1 

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ server.php
</IfModule>

If you have completed the above steps. Check your project in your browser http://localhost/Projectname/ with this link.

And you can also run the project using php artisan server command.

You can also change the port number using the command. The command is

php artisan serve --port=8001

Now you can run the project in port 8001 http://127.0.0.1:8001