How to start a Laravel Application using XAMPP

WINW > Software Development > Symfony > How to start a Laravel Application using XAMPP
  1. Install Laravel and Create a New Application:

    • Open your terminal and navigate to the directory where you want to create your Laravel application.
    • Install Laravel globally by running:
      composer global require laravel/installer
      

    • Create a new Laravel application using:
      laravel new crudposts
      

  2. Create a Database:

    • Start the Apache and MySQL servers in your XAMPP control panel.
    • Visit http://localhost/phpmyadmin in your browser.
    • Click “New” on the left sidebar to create a new database. Provide a name and click “Create.”
    • Edit your application’s .env file (located at the root of your Laravel app) with your database credentials:
      DB_CONNECTION=mysql
      DB_HOST=127.0.0.1
      DB_PORT=3306
      DB_DATABASE=your_database_name
      DB_USERNAME=your_database_username
      DB_PASSWORD=your_database_password
      

  3. Create a Table:

    • In Laravel, tables are created using migrations. Run the following command to generate a migration file:
      php artisan make:migration create_companies_table
      

    • Edit the generated migration file to define your table schema (columns, data types, etc.).
    • Run the migration to create the table:
      php artisan migrate
      

  4. Create a Controller:

    • Generate a controller for your CRUD operations:
      php artisan make:controller CompanyController
      

  5. Set Up the Model:

    • Create a model for your Company table:
      php artisan make:model Company
      

  6. Add Routes:

    • Define routes in your routes/web.php file for creating, reading, updating, and deleting companies.
  7. Generate Blade Files:

    • Create Blade views (templates) for displaying your data. For example, create views for listing companies, showing details, editing, and creating new companies.
  8. Deploy and Test Your CRUD Application:

    • Deploy your Laravel application to a server (you can use services like MyKinsta).
    • Test your CRUD functionality by adding, viewing, updating, and deleting company records.

Leave a Reply