Skip to content

ayodeleoniosun/laravel-repository

Repository files navigation

Repository pattern implementation for Laravel

This repository is a boilerplate code for using repository pattern in laravel.
It comprises accounts (guest) and authenticated user CRUD operations for example purpose.

Getting Started

  • Development Requirements
  • Installation
  • Starting Devevelopment Server
  • Documentation
  • Testing

Development Requirements

This application currently runs on Laravel 9.20 and the development requirements to get this application up and running are as follow:

  • PHP 8.1+
  • Sqlite
  • NPM
  • MySQL
  • git
  • Composer

Installation

Step 1: Clone the repository

git clone https://github.com/ayodeleoniosun/laravel-repository.git

Step 2: Switch to the repo folder

cd laravel-repository

Step 3: Install all composer dependencies

composer install

Step 5: Setup environment variable

  • Copy .env.example to .env i.e cp .env.example .env
  • Update all the variables as needed

Step 6: Generate a new application key

php artisan key:generate

Step 7: Run database migration alongside the seeders

php artisan migrate:fresh --seed

Ensure that your mysql server is up before running the above command

Starting Development Server

After the installation of the packages and running migrations, then, it's time to start the development server.

Development server can be started in three ways:

I recommend using valet or Laravel sail to start the development server to ensure that the application works perfectly across all developers' machines regardless of their operating systems.

Note:

  • If you are using Laravel sail to start your development server, your default database configuration in the .env should be as follow:
  DB_CONNECTION=mysql
  DB_HOST=mysql
  DB_PORT=3306
  DB_DATABASE=your_database_name
  DB_USERNAME=sail
  DB_PASSWORD=password

However, if you want to change the DB username and password after springing forth a docker container using the laravel sail, update the DB_USERNAME and DB_PASSWORD in the .env with the new details and then run this:

./vendor/bin/sail down -v
./vendor/bin/sail build --no-cache
./vendor/bin/sail up -d

Documentation

The Postman API collection is available Here.

Testing

You must have installed Pest in the project before running the test suites. If you haven't, kindly follow the documentation Here.
The application is currently made up of feature tests and only the RESTful endpoints were tested.

The tests can be run using:

php artisan test

About

Repository pattern implementation for Laravel

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages