Does laravel require a separate web server to run? - php

I am learning laravel for a school research project and am currently stuck at this. I have installed xampp and composer so far, I installed xampp to make use of the php.exe file that composer asks for, however, I realized that when I execute this command "php artisan serve" I am able to launch the new laravel project without having xampp running, does this mean that laravel does not require a separate server?

does this mean that laravel does not require a separate server?
Not really, php artisan serve is only meant to be used for developing environment since it uses PHP's built-in webserver.
Taken from its documentation
This web server was designed to aid application development. It may
also be useful for testing purposes or for application demonstrations
that are run in controlled environments. It is not intended to be a
full-featured web server. It should not be used on a public network.
In production you should use a better webserver such as nginx.

Related

Installing and running Laravel and PHP without admin privileges on Linux servers

There is a need for developing a web application that will be deployed on a Linux server on which I won't have admin privileges and also the internet.
I need to deploy self-contend binaries or other files on the server. I need a way to develop and deploy a web application in such a restricted environment.
My preferred development stack is Laravel but I am open for any other framework which can be used to develop the application for such a scenario.
I can only answer on Laravel's behalf: Laravel alone requires only PHP binaries. It doesn't need internet, not even composer while in production mode. You can zip the entire application with fetched dependencies from another computer and deploy it anywhere you want.
As for other software, I'm sure you can download them as tarballs and install them as basic user without root privileges. Check out the PHP site for stable Linux releases: https://www.php.net/downloads.php

How to set up React-Laravel project with out php artisan serve?

I have created a react-laravel project using laravel-mix. Right now I am run project using
npm run watch
php artisan serve
So by this, I access project by : http://localhost:8000
I have also worked in laravel. In laravel, if we want to access project without php artisan serve then we can access using : http://localhost/project_name/public.
Now my question is, how can I access/execute react-laravel project without php artisan serve? Is there any kind of way to access/execute project without port? Because I want to set up react-laravel on live server and I don't want to continue open terminal on server after code uploading.
I will really appreciate your feedbacks.
There are a multitude of ways to set up a laravel project. and it has nothing to do with the frontend suite you use whether its React or Vue, I will give you 2 options here to run a laravel application.
1. vagrant/homestead
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!
Doc Link
2. XAMPP/WAMP/ or any LAMP stack
XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.
Link
Personally I prefer Laravel Homestead since it contains everything out of the box for laravel Development. like PHP, Nginx, MariaDB, Node, etc...

How to host Laravel 5.4 application on server?

I have created an application in laravel 5.4 and I'm running it using
php artisan serve. Now I want to host it on live server. I have some question about this.
How can we build Laravel app to host on the production server? (just like Angular 2/4).
Do we always need artisan serve to run the application?
How to communicate local development and remote development via FTP or same?
First of all i highly recommend read Laravel Deployment document, that added in 5.5 documents.
Why we use from "php artisan serve":
in the local development we have 2 way to see result of our scripts.
define a domain in local and point that to public directory of your site.
use "php artisan serve" command and word imminently after getting the script.
in the remote server you just need to point public directory.
About number 3: you can first compress your files and upload to your remote server and uncompressed that in server with tools of remote server.
How can we build laravel app to host on the production server?(just like angular 2/4).
You need a web server like apache or nginx or light httpd, then you should create a virtual host to host your project code.
Do we always need artisan serve to run the application?
No. artisan serve is just a fast demonstration tool for local test. It can't supervise file modifications so you should never use it in dev or production.
How to communicate local development and remote development via FTP or same.
Some IDE can help you to synchronize files between local and remote environment like zend studio or phpstorm(itellij studio).
Try that but pay attention to file access privilege (think of difference between 755 and 644 )
but git is always the best way to keep your production code clean.
Here are the answers of your question
How can we build Laravel app to host on the production server? (just like Angular 2/4).
You need to deploy all your files exclude vendor directory, composer.json,storage. After deployment you need to run below command
composer update
composer dump-autoload
Do we always need artisan serve to run the application?
No, You need to create DNS and it should point to your public directory.
How to communicate local development and remote development via FTP or same.
There are many ways, you can choose what you are comfortable with, like, You can use FTP or you can use version control like Git etc.

What are the correct steps to deploy a production laravel 5.2 app?

I am using laravel 5.2 to develop app.
As of now I am using php -S localhost:8888 -t public to deploy the test development app.
I know that I have to change configuration file .env for production.
But itseams I can't use php artisan serve or php -S localhost:8888 -t public to deploy the app as production app.
I am using WAMP in my machine. Currently I placed my laravel app in C:\wamp\www\laravel.
What are the correct steps to deploy my laravel 5.2 app?
php artisan serve creates a local, development, very basic HTTP server and is not for production. It won't handle more than a handful of visits and will break quickly, and isn't secured in the way Apache or Nginx are.
Based on your directory path C:\wamp\www\laravel, I guess you are using a WAMP server? The A in WAMP is Apache - the web server you use instead of php artisan serve.
Setting up the site on a production server will vary based on your setup, but the general steps will look like:
You should just put your project files straight into in your WAMP directory
Run composer install to install the dependencies.
Edit the database and other vars in your .env file.
Ensure that WAMP is running and the site is configured and you should should be good to go.
If you don't have much server experience and just want to securely and simply host a Laravel app, I would strongly suggest checking our Laravel Forge - it does everything and your site will be on the public Internet within 10 minutes.

Laravel - how to serve a new laravel project to browser

This is the first time I've used a PHP framework.
I've been following the Laravel documentation to install Composer and Laravel, and everything seems to have gone smoothly.
But now I've finished the installation/configure instructions, and I have created a project, I can't see any instructions on how to serve my application so it's viewable via a browser?
I have used Ruby on Rails before, which came with an easy way to get an instance of the application running via a built-in web server.
Is there something similar with Laravel, or do I need to somehow configure my standard Apache instance to serve the application?
I'm guessing there is something I've overlooked or misunderstood in the documentation.
yes, you can do it by using following in your terminal.
open your terminal, and navigate to directory where you have your project abc
and fire following command
php artisan serve
Now you can access it in browser by going to http://localhost:8000
hope you get it
I just want to add to the answer of Mubin Khalid . You can choose your own port number like
php artisan serve --port=8080
This is helpful when running two or more project.
You can also serve with you ip address
php artisan serve --host=ip_of_computer_running_laravel --port=8080
works to access server with in same network.
if you are accessing from same laptop you can just browse to ip_of_computer_running_laravel:8080 but if you are browsing from other computer in the network ip_of_computer_running_laravel:8080

Categories