jooservices / laravel-controller
Base API Controller with standardized responses and automatic versioning
Requires
- php: ^8.5
- illuminate/http: ^12.0
- illuminate/routing: ^12.0
- illuminate/support: ^12.0
Requires (Dev)
- captainhook/captainhook: ^5.23
- captainhook/plugin-composer: ^5.3
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^3.7
- dev-develop
- 1.2.0
- 1.1.0
- 1.0.0
- dev-dependabot/composer/phpunit/phpunit-13.1.4
- dev-dependabot/composer/phpstan/phpstan-2.1.47
- dev-dependabot/github_actions/softprops/action-gh-release-3
- dev-feat/response-formatter-and-ci
- dev-dependabot/composer/phpstan/phpstan-2.1.46
- dev-dependabot/composer/squizlabs/php_codesniffer-4.0.1
- dev-dependabot/composer/phpunit/phpunit-13.1.1
- dev-release/1.1.0
This package is auto-updated.
Last update: 2026-04-15 19:27:53 UTC
README
The JOOservices Laravel Controller package provides a standardized base controller for Laravel APIs with consistent envelopes, pagination helpers, status endpoints, and exception-to-response mapping.
Package name: jooservices/laravel-controller
Install
composer require jooservices/laravel-controller
Quick example
namespace App\Http\Controllers\Api\V1; use App\Http\Resources\UserResource; use App\Models\User; use JOOservices\LaravelController\Http\Controllers\BaseApiController; class UserController extends BaseApiController { public function index() { return $this->respondWithPagination(User::paginate(), UserResource::class); } public function show(User $user) { return $this->respondWithItem($user, UserResource::class); } }
What the package supports today
- standardized JSON response envelopes for success and error states
- optional custom response formatter support for teams that need a different top-level contract
- item, collection, length-aware pagination, cursor pagination, and offset pagination helpers
- request trace correlation through
X-Trace-ID - optional HAL-style pagination and item links
- configurable
204envelope behavior, validation message strategy, and success-code range - optional status endpoint with environment, maintenance, version, and health-check metadata
- exception handling helpers designed for Laravel API controllers
Documentation
Start with:
- Documentation Hub
- Installation
- Quick Start
- Response Envelopes
- Pagination and Status
- Response Reference
AI Support
This repository now includes a lightweight AI skill pack aligned with the jooservices/dto repository structure.
Start with:
The canonical repository skills live under .github/skills/, with adapter files for GitHub Copilot and other agent runtimes.
Development
composer lint:all
composer test
Contributor workflow details live in:
GitHub Actions and Services
Composer command parity with jooservices/dto:
- core command map matches:
test,test:coverage,lint:pint,lint:pint:fix,lint:phpcs,lint:phpstan,lint:phpmd,lint,lint:all,lint:fix,check, andci - intentional differences remain: this package does not include
lint:csorlint:cs:fixbecausephp-cs-fixeris not part of this repository toolchain
Local git hook consistency:
captainhookis installed through Composer hookscommit-msg,pre-commit, andpre-pushchecks are defined incaptainhook.jsongitleaksis part of the local hook policy, matching thedtorepository conventions
Current GitHub Actions coverage:
CI: Composer audit, lint matrix, tests, coverage artifacts, optional Codecov uploadRelease: tag-driven GitHub release with optional Packagist refreshPR Labeler: applies labels from changed-file rules in.github/labeler.ymlSemantic PR Title: enforces conventional pull request titlesOpenSSF Scorecard: publishes repository security posture results as SARIFSecret Scanning: workflow exists, but thegitleaksjob is disabled untilGITLEAKS_LICENSEis configured
External services currently supported by workflows:
Codecovin.github/workflows/ci.ymlwhenCODECOV_TOKENis configuredPackagistrefresh in.github/workflows/release.ymlwhenPACKAGIST_USERNAMEandPACKAGIST_TOKENare configuredOpenSSF Scorecardin.github/workflows/scorecard.ymlGitHub SARIFupload in.github/workflows/scorecard.yml
License
This package is distributed under the MIT license.