search

Laravel Project Installation

Comments:
Likes:
Shares:
Best Division

Best Division  @bestdivision

Published On - Last Updated -

Laravel Existing Project Setup

Here's an example of how to install and set up a Laravel project:

Install Composer: Before installing Laravel, you need to have Composer installed on your system. You can download Composer from https://getcomposer.org/.

Create a new Laravel project: To create a new Laravel project, open a terminal and run the following command:

composer create-project --prefer-dist laravel/laravel project_name
  1. Change to the project directory: After creating the project, change to the project directory with the following command:
cd project_name
  1. Configure database: In your Laravel project, you need to configure the database settings in the **.env** file. You can copy the **.env.example** file to **.env** and set your database credentials. For example:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
  1. Generate application key: Laravel uses an application key to secure user sessions and other encrypted data. To generate an application key, run the following command:
php artisan key:generate
  1. Serve the application: To start a development server and serve the application, run the following command:
php artisan serve
  1. Access the application: Open your web browser and access the URL **http://localhost:8000**. You should see the default Laravel welcome page.

By following these steps, you should have a basic Laravel project installed and set up. You can start building your application by adding routes, controllers, models, and views to the project.

1: Laravel Backend and React Front End.

composer install
npm install
php artisan serve
php artisan key:generate
php artisan jwt:secret
php artisan cache:clear
php artisan config:clear

NOTE: Those who are using php version greater 8.0 then you need to do two more steps:

"require": {
    "php": "^7.0|^8.0",
    ...
}
  1. composer install --ignore-platform-reqs

2: Create a file axios.js and paste the following command.

import axios from "axios";

const instance = axios.create({
    baseURL: 'http://www.example.com/',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
});

export default instance;

3: Using Axios to make a GET request.

a) Open App.js ( the file you want to make call from ).

b) Import axios file you made in step 2. 

import React from 'react'
import axios from '../../axios';

function App() {
	const makeGetRequest = async () => {
        let response = await axios({
            method: 'get',
            url: `/users/1`
        });
        console.log(response);

    }
    makeGetRequest();
    return (
        <div>
            
        </div>
    )
}

export default App

So, the above function will make a get request and log the response in console.

Similar Blogs
0 Commentssort Sort By

@abcd 1 days ago

Aquí los que apoyamos a Los del limit desde sus inicios..

dislike
reply
sdfsdf