Skip to content

Commit

Permalink
Move to DevTheorem namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorejb committed Oct 23, 2024
1 parent d39188e commit 0b3a293
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 67 deletions.
40 changes: 20 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
<?php

use theodorejb\Phaster\{Entities, Prop, QueryOptions};
use DevTheorem\Phaster\{Entities, Prop, QueryOptions};

class Users extends Entities
{
Expand Down Expand Up @@ -90,7 +90,7 @@ protected function getBaseSelect(QueryOptions $options): SqlParams
<?php

use My\DatabaseFactory;
use theodorejb\Phaster\{Entities, EntitiesFactory};
use DevTheorem\Phaster\{Entities, EntitiesFactory};

class MyEntitiesFactory implements EntitiesFactory
{
Expand All @@ -104,7 +104,7 @@ class MyEntitiesFactory implements EntitiesFactory
```php
<?php

use theodorejb\Phaster\RouteHandler;
use DevTheorem\Phaster\RouteHandler;

$phaster = new RouteHandler(new MyEntitiesFactory());

Expand All @@ -118,7 +118,7 @@ $app->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
{
Expand Down
23 changes: 17 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace theodorejb\Phaster;
namespace DevTheorem\Phaster;

use PeachySQL\PeachySql;
use PeachySQL\QueryBuilder\SqlParams;
Expand Down
2 changes: 1 addition & 1 deletion src/EntitiesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace theodorejb\Phaster;
namespace DevTheorem\Phaster;

interface EntitiesFactory
{
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace theodorejb\Phaster;
namespace DevTheorem\Phaster;

use Teapot\{HttpException, StatusCode};

Expand Down
2 changes: 1 addition & 1 deletion src/Prop.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace theodorejb\Phaster;
namespace DevTheorem\Phaster;

use Closure;
use DateTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/QueryOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace theodorejb\Phaster;
namespace DevTheorem\Phaster;

/**
* @api
Expand Down
2 changes: 1 addition & 1 deletion src/RouteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace theodorejb\Phaster;
namespace DevTheorem\Phaster;

use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
use Teapot\{HttpException, StatusCode};
Expand Down
4 changes: 2 additions & 2 deletions test/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions test/EntitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions test/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions test/MssqlDbTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace theodorejb\Phaster\Test;
namespace DevTheorem\Phaster\Test;

use DevTheorem\Phaster\Test\src\App;
use PeachySQL\PeachySql;
use PeachySQL\SqlServer;
use theodorejb\Phaster\Test\src\App;

/**
* @group mssql
Expand Down
4 changes: 2 additions & 2 deletions test/MysqlDbTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace theodorejb\Phaster\Test;
namespace DevTheorem\Phaster\Test;

use DevTheorem\Phaster\Test\src\App;
use PeachySQL\Mysql;
use PeachySQL\PeachySql;
use theodorejb\Phaster\Test\src\App;

/**
* @group mysql
Expand Down
4 changes: 2 additions & 2 deletions test/PropTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace theodorejb\Phaster\Test;
namespace DevTheorem\Phaster\Test;

use DevTheorem\Phaster\Prop;
use PHPUnit\Framework\TestCase;
use theodorejb\Phaster\Prop;

class PropTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion test/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use theodorejb\Phaster\Test\src\{App, Config, LocalConfig};
use DevTheorem\Phaster\Test\src\{App, Config, LocalConfig};

require 'vendor/autoload.php';

Expand Down
2 changes: 1 addition & 1 deletion test/src/App.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace theodorejb\Phaster\Test\src;
namespace DevTheorem\Phaster\Test\src;

class App
{
Expand Down
2 changes: 1 addition & 1 deletion test/src/Config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace theodorejb\Phaster\Test\src;
namespace DevTheorem\Phaster\Test\src;

/**
* Default test config. Values can be overridden with a LocalConfig child class.
Expand Down
4 changes: 2 additions & 2 deletions test/src/LegacyUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace theodorejb\Phaster\Test\src;
namespace DevTheorem\Phaster\Test\src;

use DevTheorem\Phaster\{Entities, QueryOptions};
use PeachySQL\QueryBuilder\SqlParams;
use theodorejb\Phaster\{Entities, QueryOptions};

class LegacyUsers extends Entities
{
Expand Down
4 changes: 2 additions & 2 deletions test/src/ModernUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace theodorejb\Phaster\Test\src;
namespace DevTheorem\Phaster\Test\src;

use theodorejb\Phaster\{Entities, Prop, QueryOptions};
use DevTheorem\Phaster\{Entities, Prop, QueryOptions};

class ModernUsers extends Entities
{
Expand Down
6 changes: 3 additions & 3 deletions test/src/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace theodorejb\Phaster\Test\src;
namespace DevTheorem\Phaster\Test\src;

use theodorejb\Phaster\Entities;
use theodorejb\Phaster\Prop;
use DevTheorem\Phaster\Entities;
use DevTheorem\Phaster\Prop;

class Users extends Entities
{
Expand Down

0 comments on commit 0b3a293

Please sign in to comment.