-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
juris.skesters
committed
May 30, 2024
1 parent
9bd8680
commit ce25663
Showing
22 changed files
with
11,462 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: StaticAnalysis | ||
|
||
on: ['push', 'pull_request'] | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.3 | ||
tools: composer:v2 | ||
|
||
- name: Install Dependencies | ||
run: composer install --no-interaction --prefer-dist --optimize-autoloader | ||
|
||
- name: Tests | ||
run: ./vendor/bin/phpstan analyse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Tests | ||
|
||
on: ['push', 'pull_request'] | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.3 | ||
tools: composer:v2 | ||
coverage: xdebug | ||
|
||
- name: Install Dependencies | ||
run: composer install --no-interaction --prefer-dist --optimize-autoloader | ||
|
||
- name: Tests | ||
run: ./vendor/bin/pest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor/ | ||
.idea | ||
.php-cs-fixer.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
$finder = PhpCsFixer\Finder::create() | ||
->exclude( | ||
[ | ||
'vendor', | ||
] | ||
) | ||
->name('*.php') | ||
->in(__DIR__); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'@PhpCsFixer' => true, | ||
'@PHP73Migration' => true, | ||
'global_namespace_import' => true, | ||
'self_static_accessor' => true, | ||
'void_return' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'concat_space' => ['spacing' => 'one'], | ||
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], | ||
'single_quote' => ['strings_containing_single_quote_chars' => true], | ||
'yoda_style' => false, | ||
'blank_line_before_statement' => ['statements' => ['return']], | ||
'method_chaining_indentation' => false, | ||
'logical_operators' => true, | ||
'modernize_types_casting' => true, | ||
'php_unit_test_class_requires_covers' => false, | ||
'strict_comparison' => true, | ||
'psr_autoloading' => true, | ||
'combine_nested_dirname' => true, | ||
'is_null' => true, | ||
'no_alias_functions' => true, | ||
'no_unreachable_default_argument_value' => true, | ||
'dir_constant' => true, | ||
'no_alternative_syntax' => false, | ||
'method_argument_space' => false, | ||
'phpdoc_align' => ['align' => 'left'], | ||
]) | ||
->setFinder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# About Single Actions Resource Controllers | ||
|
||
This package extends Laravel Router with new feature - Route::singleActionResource() | ||
It's combination of [Route::resource](https://laravel.com/docs/11.x/controllers#resource-controllers) together | ||
with [Single Action Controllers](https://laravel.com/docs/11.x/controllers#single-action-controllers). | ||
If you are interested in small highly cohesive controller classes that follow standard naming convention this package is | ||
definitely for you. | ||
|
||
## How does it work? | ||
|
||
It's really simple: | ||
|
||
- Just add new single action resource route in your routes file, e.g `Route::singleActionResource('photos');` | ||
- Create new [Single Action Controllers](https://laravel.com/docs/11.x/controllers#single-action-controllers) for each | ||
action you need, like this: ![controllers.png](controllers.png) | ||
- This will automatically create routes these routes: ![routes.png](routes.png) | ||
|
||
## Installation | ||
|
||
You can install the package via composer: | ||
`composer require clean-bandits/single-action-resource-controllers-for-laravel` | ||
|
||
Optionally you can publish the config file with: | ||
`php artisan vendor:publish --provider="CleanBandits\SingleActionResourceControllers\SingleActionResourceControllersProvider" --tag="config"` | ||
This is the contents of the published config file: | ||
|
||
```php | ||
return [ | ||
/* | ||
* Specify root namespace where your single action resource controller folder will reside | ||
*/ | ||
'controllers_namespace' => 'App\\Http\\Controllers\\', | ||
|
||
/* | ||
* This class is responsible for building Resource controllers naming and location. | ||
* By default they reside inside namespace -> controllers_namespace+resource_name+action, | ||
* e.g. App\Http\Controllers\Photos\IndexController | ||
* To take full control of controller namespace creation, | ||
* you can provide your own class that implements ResourceController | ||
*/ | ||
'resource_controller' => DefaultResourceController::class, | ||
]; | ||
``` | ||
|
||
## Testing | ||
|
||
`composer test` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "clean-bandits/single-action-resource-controllers-for-laravel", | ||
"keywords": [ | ||
"clean-bandits", | ||
"single-action-resource-controllers-for-laravel", | ||
"laravel", | ||
"routing" | ||
], | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"CleanBandits\\SingleActionResourceControllers\\": "src/" | ||
} | ||
}, | ||
"homepage": "https://github.com/CleanBandits/single-action-resource-controllers-for-laravel", | ||
"authors": [ | ||
{ | ||
"name": "Clean Bandits" | ||
} | ||
], | ||
"require": { | ||
"php": ">=8.2", | ||
"illuminate/routing": ">=11.0" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^3.58", | ||
"orchestra/testbench": "^9.1", | ||
"pestphp/pest": "^2.34" | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"CleanBandits\\SingleActionResourceControllers\\Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "vendor/bin/pest", | ||
"code-quality": [ | ||
"@php-cs-fixer" | ||
], | ||
"php-cs-fixer": "php-cs-fixer fix" | ||
}, | ||
"config": { | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"pestphp/pest-plugin": true | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"CleanBandits\\SingleActionResourceControllers\\SingleActionResourceControllersProvider" | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.