habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

1 min read

Requirement

Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One of the most efficient ways to start a Laravel project is by utilizing Composer, a dependency manager for PHP. In this guide, we will walk through the Create Laravel Project with Composer, ensuring a smooth and streamlined development experience.

Laravel Project base PHP LAMP/LEMP stack. For running Laravel Project in development or production at least need following requirement.

  • Nginx / Apache web server.
  • PHP
  • Database

In this case, i am use package here.

  • Nginx
  • PHP and php-fpm
  • Mysql server 5.7

Read Also: ISPConfig Ubuntu 18.04 Nginx MySQL

Install Composer

Before diving into Laravel project creation, ensure that Composer is installed on your system. If you haven’t installed Composer yet, you can do so by executing the following command in your terminal.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

Create Project Laravel

Once Composer is installed, creating a new Laravel project is a breeze. Open your terminal and use the following command.

composer create-project laravel/laravel --prefer-dist laravel.habibza.in

Navigating into the Project Directory

After successfully creating the Laravel project, navigate into the project directory using the 'cd' command

cd laravel.habibza.in

Make Laravel Project With Auth (Optional)

composer require laravel/ui
php artisan ui bootstrap --auth
npm install && npm run dev

After finish, will show like this in terminal.

See also  ISPConfig Ubuntu 18.04 Nginx MySQL
php artisan serve --host=192.168.201.30 --port=8080
  • Change --host with your IP address.
  • Change --port with port that you want.

Setup Database .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_app
DB_USERNAME=u_app
DB_PASSWORD=secret_db

Database Migration and Seeding

To set up your database, run migrations and seed your database tables with sample data. Execute the following commands.

php artisan migrate
php artisan db:seed

Creating a Laravel project with Composer is a fundamental step towards building robust and scalable web applications. The combination of Laravel’s expressive syntax and Composer’s dependency management simplifies the development process. By following the steps outlined in this guide, you’ve established a solid foundation for your Laravel project and gained insights into further customization possibilities. Now, it’s time to unleash the power of Laravel and bring your web development projects to life.

Thank you for taking the time to go through this article. If you experience any challenges, need clarification, or have feedback, feel free to let me know. Hope it usefull.

Happy reading!!

habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Centos Failed Update Kernel

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel...
habibzain
1 min read

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox