vaibhavpandeyvpz/laravel-crud

This package is abandoned and no longer maintained. The author suggests using the vaibhavpandeyvpz/starter-laravel package instead.

Quick, Laravel LTS CRUD boilerplate using Livewire with RBAC.

dev-main 2022-08-13 16:09 UTC

README

Quick, Laravel LTS CRUD boilerplate using Livewire with RBAC. Has better default auth views based on Bootstrap, nicely integrates Select2 and Flatpickr as well.

Installation

Before installing, make sure to have PHP, Composer, Node.js, Yarn and either of MySQL or MariaDB installed on your workstation.

To create a new project from this template, run below command in Command Prompt, PowerShell or Terminal window:

composer create-project vaibhavpandeyvpz/starter-laravel:@dev <your-project-name>

To run the project, you can either start a local web server or run it inside a Docker container.

Local

Edit the .env file with your database information and seed the database with seeds by running below commands:

php artisan migrate --seed

Start the built-in development server using below command:

php artisan serve

Docker

This project also includes pre-configured Docker scripts for faster development as well as deployment.

Prepare

Before you start the project with Docker, you need to update below values in .env file:

APP_URL=http://localhost:8080

DB_HOST=mariadb
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

REDIS_HOST=redis

QUEUE_CONNECTION=redis

AWS_ACCESS_KEY_ID=accessKey1
AWS_SECRET_ACCESS_KEY=verySecretKey1
AWS_BUCKET=laravel
AWS_ENDPOINT=http://zenko:8000
AWS_ENDPOINT_PATH_STYLE=true

Development

To start the application, run below command in Command Prompt, PowerShell or Terminal window:

docker-compose up -d

The web container also includes composer for you to carry out common tasks, some basic examples are below:

# install any PHP package
docker-compose exec web composer require <package-name>

# run migrations and seed database
docker-compose exec web php artisan migrate --seed

Before you start to use the bundled S3-compatible cloud storage, you will need to create the bucket as follows:

# open a shell
docker-compose exec web sh

# start a tinker session
php artisan tinker

# copy/paste and run below PHP code
$client = Storage::cloud()->getAdapter()->getClient();
$result = $client->createBucket(['Bucket' => config('filesystems.disks.s3.bucket')]);

Deployment

To build an image for deployment and publish the image to a registry e.g., Docker Hub, use command as below:

# build and tag image
docker build -t vaibhavpandeyvpz/starter-laravel .

# push image to registry
docker push vaibhavpandeyvpz/starter-laravel

Backend

Lastly, you may access the backend at http://localhost:8000/ or http://localhost:8080/ (if using Docker) in your favorite web browser and register for an account. Then assign newly created user with administrator privileges by running below command with its email:

# if developing locally
php artisan app:assign-admin <email-address-of-the-user>

# if using Docker
docker-compose exec web php artisan app:assign-admin <email-address-of-the-user>

Best practices

To enforce recommended coding style across project, this project also includes configuration for PHP CS Fixer be default. Before committing your changes, you may run below command to test your code against any such issue.

# if developing locally
./vendor/bin/php-cs-fixer fix --show-progress=dots -vvv

# if using Docker
docker-compose exec web vendor/bin/php-cs-fixer fix --show-progress=dots -vvv