Starting with the Laravel

starting with laravel

The laravel framework uses Composer for dependency management.

Creating a Project

To create a new project in the laravel open command prompt in your web server and type the following command.

composer create-project --prefer-dist laravel/laravel project_name

This will create a new project using a composer with the name specified in place of project_name.

Running Application

To serve or view the project output on the browser we use artisan serve command. A laravel framework command-line interface. Access the project folder in your command prompt and run the following command.

php artisan serve

This will start the laravel development server at http://127.0.0.1:8000. go through the link to view the laravel application you have installed.

Create a Database

To use a database with your application go through the following steps.

  • To create a database go to your MySQL admin panel. and create a database with the name of your choice.
  • Open your application folder in any IDE.
  • Open .env.example file and rename it as .env.
    It will be having some predefined variables as follows

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=database_name
    DB_USERNAME=database_username
    DB_PASSWORD=database_password
  • Place your database name.
  • Your database username.
  • Your MySQL database password.

Directory permissions

If you are using a Linux or Unix system you have to set writable permission for directories within the storage and the bootstrap/cache directories. Run the following command to give permission.

chmod -R 755 storage/ bootstrap/cache

Note: Before changing your application .env file you have to stop your
laravel development server by pressing Ctrl+C keys, and then
start the laravel development server.

OR

You have to restart your laravel development server to implement changes in env file.