Go to this directory:
[email protected] MINGW64 /c/xampp/htdocs/Laravel_Project
Via Composer Create-Project:
Install Laravel by using the Composer create-project command in your terminal:
composer create-project --prefer-dist laravel/laravel news_portal
After you hit enter in your terminal it will automatically start to download the required components in your project folder. In my case I have provided project name as news_portal, You can provide a project name in your wish. So it will create the project name as news_portal and install the required components. It will take a few minutes to install the components.
You will see the following screenshot:
Fig:Installation news_portal screenshot.
Fig:Folder screenshot after a successful installation of project.
Local Development Server:
If you have PHP installed locally and you would like to use PHP’s built-in development server to serve your application, you may use the serve Artisan command. This command will start a development server at http://127.0.0.1:8000
php artisan serve
You will see the following screenshot if your project has been installed successfully.
Fig:Screenshot after running a server
If your installation is completed then you can run the project through the local server but be sure you are in the directory /c/xampp/htdocs/Laravel_Project/news_portal
Otherwise, if you give the command in the same directory i.e /c/xampp/htdocs/Laravel_Project .Then you will get the following error.
Why Local development server?
If you run the project through the local development server i.e http://127.0.0.1:8000 then it will directly point the following directory:
But if you are going to run the project manually then you have to enter the following path in your browser which is a lengthy process.
If you wish to stop the server then simply press Ctrl + c command.
You can run the project which is in your system through the virtual host also. So, in order to run the project through the virtual host, you have to configure the following:
Go to C:\Windows\System32\drivers\etc path and you have to add the domain name. I have provided virtual host domain name as newsportal.test. In your case, you can provide any.
127.0.0.1 localhost 127.0.0.1 newsportal.test
Screenshot of notepad:
Fig:Adding a domain name screenshot
Go to C:\xampp\apache\conf\extra path and you have to add the following:
<VirtualHost *:80> DocumentRoot "C:/xampp/htdocs" ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/Laravel_Project/news_portal/public" ServerName newsportal.test </VirtualHost>
After this configuration you have to restart your apache server(XAMPP server).
Fig:Adding virtual host name screenshot
Fig:Screenshot after running a project in virtual host:
Running through the virtual host is the best option because it is not necessary to give the command like php artisan serve every time which is done in the local development server.