nucleardog / ndapi-debug
API boilerplate for Laravel - debug tools
Requires
- php: ^8.2
- nucleardog/discovery: ^1.0
- nucleardog/ndapi-common: ^1.0
This package is auto-updated.
Last update: 2024-12-25 00:26:17 UTC
README
Part of the ndapi package. Provides a system for registering and reporting on application diagnostics meant for dev-time debugging.
Usage
Artisan Command
This package provides an artisan command to report on diagnostic checks:
Syntax:
$ artisan ndapi:diagnose [options]
Available options are:
-a
: Also report passing checks.--json
: Render output as JSON
Example:
$ artisan ndapi:diagnose -a
exceptionHandler
Discovered Exception Response classes ............................ [PASS]
responses AuthenticationExceptionResponse
AuthorizationExceptionResponse
ExceptionResponse
ModelNotFoundExceptionResponse
NotFoundHttpExceptionResponse
ValidationExceptionResponse
responses
Discovered Response classes ...................................... [PASS]
responses accepted
created
error
fail
success
ResponseFactory is macroable ..................................... [PASS]
support
Discovered helper classes ........................................ [PASS]
helpers Nucleardog\Api\Support\ArrayHelpers
Nucleardog\Api\Support\StringHelpers
$
Implementing Diagnostics
You can:
- Implement the
Nucleardog\Api\Contracts\Debug\Diagnostic
contract and register your Diagnostic with the DiagnosticsManager class. - Register a closure with the DiagnosticsManager returning a DiagnosticResult.
- Wrap your closure in the provided SimpleDiagnostic wrapper which handles translating various types of results into a properly formatted DiagnosticResult.
In any case, you can then register the Diagnostic by:
- If you have implemented the Diagnostic contract, it will be discovered and registered automatically.
- Use the service container:
app()->make(DiagnosticsManager::class)->add($diagnostic);
- Use the facade:
\Nucleardog\Api\Support\Facades\Diagnostics::add($diagnostic);
Tests
Phpunit is included in a separate composer file and must be explicitly installed:
$ cd tools/phpunit/
$ composer install
Once installed, the tests can be run from the root package folder with:
$ composer test
Legal
Copyright 2024 Adam Pippin hello@adampippin.ca
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.