Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrpunyapal/basic-crud
Example of crud operations best practices for beginner to advanced
https://github.com/mrpunyapal/basic-crud
Last synced: 1 day ago
JSON representation
Example of crud operations best practices for beginner to advanced
- Host: GitHub
- URL: https://github.com/mrpunyapal/basic-crud
- Owner: MrPunyapal
- Created: 2023-12-05T14:30:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-14T16:57:25.000Z (9 days ago)
- Last Synced: 2024-12-14T19:07:04.401Z (9 days ago)
- Language: PHP
- Homepage:
- Size: 1.34 MB
- Stars: 138
- Watchers: 9
- Forks: 38
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Laravel CRUD Operations Best Practices Example Beginner to Advanced
[![Tests](https://github.com/mr-punyapal/basic-crud/actions/workflows/tests.yml/badge.svg)](https://github.com/mr-punyapal/basic-crud/actions/workflows/tests.yml)
## Getting Started ๐
These instructions will guide you through setting up the project on your local machine for development and testing.
### Prerequisites
You need to have installed the following software:
- PHP 8.3
- Composer 2.0.8
- Node 20.10.0### Installing
Follow these steps to set up a development environment:
1. **Clone the repository**
```bash
git clone https://github.com/mr-punyapal/basic-crud.git
```2. **Install dependencies**
```bash
composer install
``````bash
npm install
```3. **Duplicate the .env.example file and rename it to .env**
```bash
cp .env.example .env
```4. **Generate the application key**
```bash
php artisan key:generate
```5. **Run migration and seed**
```bash
php artisan migrate --seed
```6. **Run the application**
```bash
npm run dev
``````bash
php artisan serve
```## How to Test the Application ๐งช
- Copy .env.testing.example to .env.testing
- Run the following commands```bash
php artisan key:generate --env=testing
``````bash
npm install && npm run build
``````bash
# Lint the code using Pint
composer lint
composer test:lint# Refactor the code using Rector
composer refactor
composer test:refactor# Run PHPStan
composer test:types# Run type coverage
composer test:type-coverage# Run the test suite
composer test:unit# Run all the tests
composer test
```
Check [composer.json](/composer.json#L78-L92) for more details on scripts.### Installing with Sail
Laravel Sail is helpful when your local environment doesn't match with project requirements like different PHP versions.
Only requirement is Docker to work with this project. For more details on Laravel Sail click [here](https://laravel.com/docs/10.x/sail).Follow these steps to set up a development environment using Laravel Sail:
1. **Clone the repository**
```bash
git clone https://github.com/mr-punyapal/basic-crud.git
```2. **Duplicate the .env.example file and rename it to .env**
```bash
cp .env.example .env
```3. **Install dependencies**
```bash
docker run --rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/var/www/html" \
-w /var/www/html \
laravelsail/php83-composer:latest \
composer install --ignore-platform-reqs
``````bash
./vendor/bin/sail run --rm laravel.test npm install
```4. **Run the application**
```bash
./vendor/bin/sail up -d
``````bash
./vendor/bin/sail npm run dev
```5. **Generate the application key**
```bash
./vendor/bin/sail artisan key:generate
```6. **Run migration and seed**
```bash
./vendor/bin/sail artisan migrate --seed
```
## How to Test the Application with Sail ๐งช- Copy .env.testing.example to .env.testing
- Run the following commands```bash
./vendor/bin/sail artisan key:generate --env=testing
``````bash
./vendor/bin/sail npm install && ./vendor/bin/sail npm run build
``````bash
./vendor/bin/sail run --rm laravel.test composer test
```
### Give Feedback ๐ฌGive your feedback on [@MrPunyapal](https://x.com/MrPunyapal)
### Contribute ๐ค
Contribute if you have any ideas to improve this project.