diff --git a/CHANGELOG.md b/CHANGELOG.md index 65cfc80..1105394 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -154,23 +154,23 @@ return early if passed an empty IDs array. ### Changed - Initial stable release -[2.9.0]: https://github.com/theodorejb/phaster/compare/v2.8.0...v2.9.0 -[2.8.0]: https://github.com/theodorejb/phaster/compare/v2.7.0...v2.8.0 -[2.7.0]: https://github.com/theodorejb/phaster/compare/v2.6.0...v2.7.0 -[2.6.0]: https://github.com/theodorejb/phaster/compare/v2.5.0...v2.6.0 -[2.5.0]: https://github.com/theodorejb/phaster/compare/v2.4.0...v2.5.0 -[2.4.0]: https://github.com/theodorejb/phaster/compare/v2.3.0...v2.4.0 -[2.3.0]: https://github.com/theodorejb/phaster/compare/v2.2.2...v2.3.0 -[2.2.2]: https://github.com/theodorejb/phaster/compare/v2.2.1...v2.2.2 -[2.2.1]: https://github.com/theodorejb/phaster/compare/v2.2.0...v2.2.1 -[2.2.0]: https://github.com/theodorejb/phaster/compare/v2.1.0...v2.2.0 -[2.1.0]: https://github.com/theodorejb/phaster/compare/v2.0.0...v2.1.0 -[2.0.0]: https://github.com/theodorejb/phaster/compare/v1.2.2...v2.0.0 -[1.2.2]: https://github.com/theodorejb/phaster/compare/v1.2.1...v1.2.2 -[1.2.1]: https://github.com/theodorejb/phaster/compare/v1.2.0...v1.2.1 -[1.2.0]: https://github.com/theodorejb/phaster/compare/v1.1.1...v1.2.0 -[1.1.1]: https://github.com/theodorejb/phaster/compare/v1.1.0...v1.1.1 -[1.1.0]: https://github.com/theodorejb/phaster/compare/v1.0.2...v1.1.0 -[1.0.2]: https://github.com/theodorejb/phaster/compare/v1.0.1...v1.0.2 -[1.0.1]: https://github.com/theodorejb/phaster/compare/v1.0.0...v1.0.1 -[1.0.0]: https://github.com/theodorejb/phaster/tree/v1.0.0 +[2.9.0]: https://github.com/DevTheorem/Phaster/compare/v2.8.0...v2.9.0 +[2.8.0]: https://github.com/DevTheorem/Phaster/compare/v2.7.0...v2.8.0 +[2.7.0]: https://github.com/DevTheorem/Phaster/compare/v2.6.0...v2.7.0 +[2.6.0]: https://github.com/DevTheorem/Phaster/compare/v2.5.0...v2.6.0 +[2.5.0]: https://github.com/DevTheorem/Phaster/compare/v2.4.0...v2.5.0 +[2.4.0]: https://github.com/DevTheorem/Phaster/compare/v2.3.0...v2.4.0 +[2.3.0]: https://github.com/DevTheorem/Phaster/compare/v2.2.2...v2.3.0 +[2.2.2]: https://github.com/DevTheorem/Phaster/compare/v2.2.1...v2.2.2 +[2.2.1]: https://github.com/DevTheorem/Phaster/compare/v2.2.0...v2.2.1 +[2.2.0]: https://github.com/DevTheorem/Phaster/compare/v2.1.0...v2.2.0 +[2.1.0]: https://github.com/DevTheorem/Phaster/compare/v2.0.0...v2.1.0 +[2.0.0]: https://github.com/DevTheorem/Phaster/compare/v1.2.2...v2.0.0 +[1.2.2]: https://github.com/DevTheorem/Phaster/compare/v1.2.1...v1.2.2 +[1.2.1]: https://github.com/DevTheorem/Phaster/compare/v1.2.0...v1.2.1 +[1.2.0]: https://github.com/DevTheorem/Phaster/compare/v1.1.1...v1.2.0 +[1.1.1]: https://github.com/DevTheorem/Phaster/compare/v1.1.0...v1.1.1 +[1.1.0]: https://github.com/DevTheorem/Phaster/compare/v1.0.2...v1.1.0 +[1.0.2]: https://github.com/DevTheorem/Phaster/compare/v1.0.1...v1.0.2 +[1.0.1]: https://github.com/DevTheorem/Phaster/compare/v1.0.0...v1.0.1 +[1.0.0]: https://github.com/DevTheorem/Phaster/tree/v1.0.0 diff --git a/README.md b/README.md index b11285e..77b0f98 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ # Phaster -Phaster is a library for easily creating RESTful API endpoints. -It works well with the Slim Framework, and supports PHP 7.4+. +Phaster is a PSR-7 compatible library for easily making CRUD API endpoints. +It enables mapping API fields to columns in the database or from a select query, +and implementing custom validation or row modification logic. +Built on top of [PeachySQL](https://github.com/DevTheorem/PeachySQL). ## Installation -`composer require theodorejb/phaster` +`composer require devtheorem/phaster` ## Usage -Create a class extending `theodorejb\Phaster\Entities` and implement the -`getMap()` method. By default, the table name will be inferred from the -class name, and all mapped columns in this table will be selected. +Create a class extending `Entities` and implement the `getMap()` method. By default, the table +name will be inferred from the class name, and all mapped columns in this table will be selected. -To join other tables and alter output values, implement the `getBaseQuery()` -and `getPropMap()` methods. Pass the callable returned by the route handling -functions to your Slim or other PSR-7 compatible framework. +To join other tables and alter output values, implement the `getBaseQuery()` and `getSelectProps()` methods. +Pass the callable returned by the route handling functions to your Slim or other PSR-7 compatible framework. ```php delete('/users/{id}', $phaster->delete(Users::class)); ### Example API request/response -GET https://example.com/api/users?q[firstName]=Ted&q[isDisabled]=0&fields=id,username,role +GET `https://example.com/api/users?q[firstName]=Ted&q[isDisabled]=0&fields=id,username,role` ```json { diff --git a/composer.json b/composer.json index 69d4a96..e88bea7 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,15 @@ { - "name": "theodorejb/phaster", - "description": "A library for quick RESTful APIs", + "name": "devtheorem/phaster", + "description": "A PSR-7 compatible library for making CRUD API endpoints", "type": "library", "license": "MIT", + "keywords": [ + "API", + "CRUD", + "database", + "PSR-7", + "REST" + ], "authors": [ { "name": "Theodore Brown", @@ -12,9 +19,9 @@ "require": { "php": ">=8.1", "ext-json": "*", + "devtheorem/peachy-sql": "^6.3.1", "psr/http-message": "^1.1 || ^2.0", - "shrikeh/teapot": "^2.3.1", - "theodorejb/peachy-sql": "^6.3" + "shrikeh/teapot": "^2.3.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.64", @@ -23,10 +30,14 @@ "vimeo/psalm": "^5.26" }, "autoload": { - "psr-4": {"theodorejb\\Phaster\\": "src/"} + "psr-4": { + "DevTheorem\\Phaster\\": "src/" + } }, "autoload-dev": { - "psr-4": {"theodorejb\\Phaster\\Test\\": "test/"} + "psr-4": { + "DevTheorem\\Phaster\\Test\\": "test/" + } }, "config": { "sort-packages": true diff --git a/src/Entities.php b/src/Entities.php index 99eb72e..1574fb8 100644 --- a/src/Entities.php +++ b/src/Entities.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace theodorejb\Phaster; +namespace DevTheorem\Phaster; use PeachySQL\PeachySql; use PeachySQL\QueryBuilder\SqlParams; diff --git a/src/EntitiesFactory.php b/src/EntitiesFactory.php index 747a9f8..ae0aef7 100644 --- a/src/EntitiesFactory.php +++ b/src/EntitiesFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace theodorejb\Phaster; +namespace DevTheorem\Phaster; interface EntitiesFactory { diff --git a/src/Helpers.php b/src/Helpers.php index 6802e79..de8cffc 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace theodorejb\Phaster; +namespace DevTheorem\Phaster; use Teapot\{HttpException, StatusCode}; diff --git a/src/Prop.php b/src/Prop.php index 33adc68..8915d5b 100644 --- a/src/Prop.php +++ b/src/Prop.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace theodorejb\Phaster; +namespace DevTheorem\Phaster; use Closure; use DateTimeZone; diff --git a/src/QueryOptions.php b/src/QueryOptions.php index 28827d4..54b0e90 100644 --- a/src/QueryOptions.php +++ b/src/QueryOptions.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace theodorejb\Phaster; +namespace DevTheorem\Phaster; /** * @api diff --git a/src/RouteHandler.php b/src/RouteHandler.php index 8b83610..f94b9d5 100644 --- a/src/RouteHandler.php +++ b/src/RouteHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace theodorejb\Phaster; +namespace DevTheorem\Phaster; use Psr\Http\Message\{ResponseInterface, ServerRequestInterface}; use Teapot\{HttpException, StatusCode}; diff --git a/test/DbTestCase.php b/test/DbTestCase.php index c921ae9..b11e13b 100644 --- a/test/DbTestCase.php +++ b/test/DbTestCase.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace theodorejb\Phaster\Test; +namespace DevTheorem\Phaster\Test; +use DevTheorem\Phaster\Test\src\{LegacyUsers, ModernUsers, Users}; use PeachySQL\PeachySql; use PHPUnit\Framework\TestCase; -use theodorejb\Phaster\Test\src\{LegacyUsers, ModernUsers, Users}; abstract class DbTestCase extends TestCase { diff --git a/test/EntitiesTest.php b/test/EntitiesTest.php index 74b9bd5..9b399f0 100644 --- a/test/EntitiesTest.php +++ b/test/EntitiesTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace theodorejb\Phaster\Test; +namespace DevTheorem\Phaster\Test; +use DevTheorem\Phaster\{Entities, Helpers}; use PHPUnit\Framework\TestCase; use Teapot\HttpException; -use theodorejb\Phaster\{Entities, Helpers}; class EntitiesTest extends TestCase { diff --git a/test/HelpersTest.php b/test/HelpersTest.php index 2ad519f..9824d5f 100644 --- a/test/HelpersTest.php +++ b/test/HelpersTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace theodorejb\Phaster\Test; +namespace DevTheorem\Phaster\Test; +use DevTheorem\Phaster\{Helpers, Prop}; use PHPUnit\Framework\TestCase; use Teapot\HttpException; -use theodorejb\Phaster\{Helpers, Prop}; class HelpersTest extends TestCase { diff --git a/test/MssqlDbTest.php b/test/MssqlDbTest.php index 1c8691f..4347acb 100644 --- a/test/MssqlDbTest.php +++ b/test/MssqlDbTest.php @@ -1,10 +1,10 @@