This repository is a boilerplate code for using repository pattern in laravel.
It comprises accounts (guest)
and authenticated user CRUD operations for example purpose.
- Development Requirements
- Installation
- Starting Devevelopment Server
- Documentation
- Testing
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
git clone https://github.com/ayodeleoniosun/laravel-repository.gitcd laravel-repositorycomposer install- Copy
.env.exampleto.envi.ecp .env.example .env - Update all the variables as needed
php artisan key:generatephp artisan migrate:fresh --seedEnsure that your mysql server is up before running the above command
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:
- Using
php artisan serve - Using Valet
- Docker via Laravel sail
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.
- 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=passwordHowever, 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 -dThe Postman API collection is available Here.
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