Skip to content

Commit

Permalink
Init commit: Package skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
axyr committed Aug 13, 2024
0 parents commit 8ca73ee
Show file tree
Hide file tree
Showing 13 changed files with 10,099 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
45 changes: 45 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Run Tests - Current"

on: [ push, pull_request ]

jobs:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 8.3, 8.2 ]
laravel: [ "^11.0" ]
dependency-version: [ prefer-lowest, prefer-stable ]
include:
- laravel: "^11.0"
testbench: 9.*
exclude:
- laravel: "^11.0"
php: 8.1

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mailparse, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: none

- name: Install dependencies (remove passport)
run: composer remove --dev laravel/passport --no-interaction --no-update
if: matrix.laravel == '^8.12'

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "symfony/console:>=4.3.4" "mockery/mockery:^1.3.2" "nesbot/carbon:>=2.62.1" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
9 changes: 9 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
php:
preset: laravel
disabled:
- no_unused_imports
finder:
not-name:
- index.php
js: true
css: true
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 📨 Another Laravel CRUD Generator

Another Laravel CRUD generator.

This generator only generates the PHP files for a route model based resource controllers.

Not frontend, no UI, just JSON based backend code.

## Repository and QueryFilter based controllers
This package is a bit different, as it will include Repository and QueryFilter classes for each CRUD.

The Repositories are very simple classes that wire up the QueryFilters with the Controllers.

The QueryFilters are based on the outstanding Laracasts tutorial:

https://laracasts.com/series/eloquent-techniques/episodes/4

THe biggest difference with this implementation of the Dedicated Query filters, is that we use a plain array instead of the Request object.
This makes it easier to reuse the Filters in Jobs, where you don't want to serialize the Request object.

https://github.com/axyr/laravel-query-filters

## Generated files

The generate command will generate the following files:

- Model
- Controller
- Resources
- Requests
- Policy
- Factory
- migration
- Repository
- Filter
- ControllerTest
- ControllerAuthorisationTest
- FilterTest

## Modules

By Default the files will be installed in a app/Modules/{Model} directory.

The philosophy here is that with Repositories, Filters and Policy classes, we are highly likely creating an above average complex application,
where we want strict separation of concerns from the start and not only groupd files by type only.
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "axyr/laravel-crud-generator",
"description": "Opiniated Laravel CRUD generator for a Module/Repository/Filter based CRUD setup.",
"type": "library",
"autoload": {
"psr-4": {
"Axyr\\CrudGenerator\\": "src/"
}
},
"authors": [
{
"name": "Martijn van Nieuwenhoven",
"email": "[email protected]"
}
],
"require": {
"php": "^8.2",
"laravel/framework": "^11.9"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"orchestra/testbench": "^9.1"
}
}
Loading

0 comments on commit 8ca73ee

Please sign in to comment.