Laravel Vue Chat is a demo project used originally for an interview task. It uses Laravel 10 for the backend, Vue 3 for the frontend, and marries the two using Inertia.js. This project provides features of a holistic chat application, with an optional AI chatbot powered by OpenAI's GPT.
Laravel is a robust MVC PHP framework, Vue.js is a progressive JavaScript framework for building user interfaces, and Inertia.js is a library that combines the best of both to create a single-page application.
Before you begin, ensure you have the following installed on your local development machine:
- PHP 8.1 or later
- Composer - A PHP dependency management tool.
- Node.js and NPM - Node.js is a server-side JavaScript runtime environment. NPM is a package manager for Node.js.
Follow these steps to setup the Laravel Vue Chat:
-
Clone the repository:
git clone https://github.com/treyan94/chat-laravel.git
-
Navigate into the project directory:
cd chat-laravel
-
Install the Composer dependencies:
composer install
-
Install the NPM dependencies:
npm install
-
Create a copy of your
.env.example
file and rename it to.env
. This file houses all your environment variables.cp .env.example .env
Obtain your API keys for Pusher which is used for enabling real-time bidirectional communication and optionally for OpenAI if you plan on using the AI Chatbot.
Note: Be sure you enter your Pusher API keys BEFORE proceeding to the next step.
-
Build your frontend assets:
npm run build
-
Generate and set your application key:
php artisan key:generate
-
Set up the database in your
.env
file. If you are using SQLite, you first need to create a new SQLite database file. This can be done with the touch command in your terminal:touch database/database.sqlite
After creating the file, update your
.env
to reflect these database settings:DB_CONNECTION=sqlite DB_DATABASE=/absolute/path/to/database/database.sqlite
Remember to replace
/absolute/path/to/database/database.sqlite
with the actual path to yoursqlite
database file. Your SQLite database is now ready for the migrations. -
Execute the database migrations and seeding:
php artisan migrate --seed
-
Bootstrap the queue worker:
php artisan queue:work
-
Fire up the application:
php artisan serve
Upon successful setup, you will be able to access the application from your specified port, usually: http://localhost:8000
.