shirokovnv / model-reflection
Package to reflect the properties and methods of the model
Requires
- php: ^7.4|^8.0
- ext-json: *
- doctrine/dbal: ~2.10|~3.0
- illuminate/contracts: ~5.8|~6|~7|~8|~9
- illuminate/database: ^5.8|^6.0|^7.0|^8.0|^9.0
- illuminate/support: ~5.8|~6|~7|~8|~9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- orchestra/testbench: ~5|~6|~7
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ~9.0
This package is auto-updated.
Last update: 2024-11-18 20:30:20 UTC
README
The package allows you to reflect properties and methods of the model and save received information in form of a JSON schema.
Installation
Via Composer
$ composer require shirokovnv/model-reflection
Usage
This package is based on Doctrine/DBAL
Once installed you can do stuff like this:
$user_schema = ModelReflection::reflect(\App\Models\User::class);
this will return ReflectedModel containing information about:
- class name
- table name
- fields
- relations
- table foreign keys
- scopes
or you can do:
$user_schema->toArray();
this will return an associative array for JSON representation.
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email shirokovnv@gmail.com instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.