is it necessary to use php artisan serve every time?
Clash Royale CLAN TAG#URR8PPP
is it necessary to use php artisan serve every time?
I am new to Laravel and I use
php artisan serve
every time to use Laravel. Is it necessary to use this command every time for using Laravel?
Install a
WAMP
, MAMP
or LAMP
(or similar) stack as a local development environment, configure a url like myapp.com
to point to your project's public
folder, and navigate away.– Tim Lewis
Aug 10 at 14:10
WAMP
MAMP
LAMP
myapp.com
public
but i am using it on windows
– Harjot Singh
Aug 10 at 14:11
@HarjotSingh You can install some software (like Homestead, WAMP, XAMPP or MAMP) and use that to create a webserver on your computer. Doesn't matter that you're using Windows.
– Douwe de Haan
Aug 10 at 14:13
3 Answers
3
You can configure nginx or apache2, so wont need to run the command each time.
In production you will need a real http server.
try this to configure apache for laravel project, or this for nginx with laravel
He means for local development, not server. These solutions would be perfect for a webserver, not a local one
– Douwe de Haan
Aug 10 at 14:13
in the C:WindowsSystem32driversetc
open the hosts file. Add this to the bottom of the content.
C:WindowsSystem32driversetc
192.168.1.120(Your local IP) test.local
save the file.
Then open the conf file from your apache server. For example if you are using xampp, in the C:xamppapacheconfextra
open the httpd-vhosts.conf
file.
C:xamppapacheconfextra
httpd-vhosts.conf
Add this to the bottom of the content.
<VirtualHost example.local:80>
DocumentRoot "C:/yourprojectfolder/public/"
ServerAdmin admin@example.local
ServerName example.local
<Directory "C:/yourprojectfolder/public/">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
Then you can access the project without artisan. In the browser open the http://example.local/
ta da!
PHP is server-side scripting language and needs a special environment to run. It's a http server.
So the answer is yes. You have to use a server to run application.
Laravel has one built in which you run by:
php artisan serve
Of course you can use another web server like Apache, Ngix but this is question to another topic something like "How to run Laravel app on Apache".
yes i have xampp in pc, if i want to use laravel i first start xampp then use php artisan serve in cmd ... if i close the cmd the framework did not works
– Harjot Singh
Aug 11 at 10:58
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Of course not, that's just a way to launch a development server. I suggest you read the docs, Laravel also has Homestead and Valet (for Mac). You wouldn't want to use artisan serve in production.
– Devon
Aug 10 at 13:56