klimesf / nette-hateoas
Hateoas integration into Nette Framework.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 1 844
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >= 5.4
- nette/application: ^2.3
- nette/di: ^2.3
- willdurand/hateoas: ^2.8
Requires (Dev)
- nette/tester: ^1.5
- tracy/tracy: ^2.3
This package is not auto-updated.
Last update: 2021-12-11 02:51:21 UTC
README
Hateoas integration into Nette Framework.
For documentation, please refer to Hateoas GitHub or to Official Hateoas webpage.
Requirements
Hateoas requires
- PHP 5.4 or higher
- Nette Framework
- Hateoas
Installation
Install Hateoas via Composer.
composer require klimesf/nette-hateoas
Configuration
services: myUrlGenerator: App\My\DefaultUrlGenerator myOtherUrlGenerator: App\My\OtherUrlGenerator extensions: hateoas: Klimesf\Hateoas\DI\HateoasExtension hateoas: cacheDir: %tempDir%/cache/hateoas debugMode: %debugMode% jsonSerializer: App\My\JsonSerializer xmlSerializer: App\My\XmlSerializer urlGenerators: - App\My\DefaultUrlGenerator other: App\My\OtherUrlGenerator expressionContextVariables: foo: "value" bar: "value" expressionLanguage: App\My\ExpressionLanguage expressionFunctions: - App\My\ExpressionFunction - App\My\OtherExpressionFunction relationProviderResolvers: - App\My\RelationProviderResolver - App\My\OtherRelationProviderResolver
All the Url generators must be registered as services.
Usage
Require Hateoas\Hateoas
class and send the json.
class MyPresenter extends Nette\Application\UI\Presenter { /** @var Hateoas\Hateoas @inject */ public $hateoas; public function actionDefault() { $entity = // ... $json = $this->hateoas->serialize($entity, 'json'); $this->sendResponse(new Klimesf\Hateoas\HalJsonResponse($json)); // Sends HAL JSON response } }