{"id":14965539,"url":"https://github.com/brandembassy/slim-nette-extension","last_synced_at":"2026-01-27T18:26:13.156Z","repository":{"id":30614392,"uuid":"125491854","full_name":"BrandEmbassy/slim-nette-extension","owner":"BrandEmbassy","description":"Nette Extension for Slim API micro-framework using middlewares.","archived":false,"fork":false,"pushed_at":"2025-02-20T13:22:57.000Z","size":175,"stargazers_count":18,"open_issues_count":9,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T19:07:49.922Z","etag":null,"topics":["api","middleware","nette","nette-di","nette-framework","single-action-controller","slim"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BrandEmbassy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-16T09:09:46.000Z","updated_at":"2023-10-25T10:01:37.000Z","dependencies_parsed_at":"2024-05-16T16:26:36.555Z","dependency_job_id":"7172de4c-5e63-4610-9308-eec69b96c4db","html_url":"https://github.com/BrandEmbassy/slim-nette-extension","commit_stats":{"total_commits":54,"total_committers":8,"mean_commits":6.75,"dds":0.5,"last_synced_commit":"6576f57bfe2f3da1bd65e11102c1c5351f6fb097"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrandEmbassy%2Fslim-nette-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrandEmbassy%2Fslim-nette-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrandEmbassy%2Fslim-nette-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrandEmbassy%2Fslim-nette-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrandEmbassy","download_url":"https://codeload.github.com/BrandEmbassy/slim-nette-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248112232,"owners_count":21049621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","middleware","nette","nette-di","nette-framework","single-action-controller","slim"],"created_at":"2024-09-24T13:34:53.255Z","updated_at":"2026-01-27T18:26:13.151Z","avatar_url":"https://github.com/BrandEmbassy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/BrandEmbassy/slim-nette-extension.svg?style=svg)](https://circleci.com/gh/BrandEmbassy/slim-nette-extension)\n[![Total Downloads](https://poser.pugx.org/BrandEmbassy/slim-nette-extension/downloads)](https://packagist.org/packages/brandembassy/slim-nette-extension)\n[![Latest Stable Version](https://poser.pugx.org/BrandEmbassy/slim-nette-extension/v/stable)](https://github.com/BrandEmbassy/slim-nette-extension/releases)\n\n# Nette Extension for integration of SLIM for API\n\nThis extension brings the power of [Slim](https://www.slimframework.com/) for applications using [Nette DI](https://github.com/nette/di). It enables you to easily work with Slim middleware stack and develop your API easily.\n\nThe general idea has been discussed in this [article](https://petrhejna.org/blog/api-chain-of-responsibility-approach). (Czech language) \n\n## Philosophy\n\n### Single Responsibility\nThe main idea is to delegate responsibilities of the code handling requests to separated middlewares. For example:\n* authentication\n* validation\n* business logic\n\nHow middlewares in Slim work is described [here](https://www.slimframework.com/docs/v3/concepts/middleware.html).\n\n### Easy configuration\nEmpowered by Nette DI and it's `neon` configuration syntax this package provides powerful and easy way to define your API.\n\n## Usage\nSo let's start!\n```\ncomposer require brandembassy/slim-nette-extension\n```\n\n### Extension\nNow register new extension by adding this code into your `config.neon`:\n```yaml\nextensions:\n    slimApi: BrandEmbassy\\Slim\\DI\\SlimApiExtension # Register extension\n\nslimApi: # Configure it\n    slimConfiguration:\n        settings:\n            removeDefaultHandlers: true # It's recommended to disable original error handling \n                                        # and use your own error handlers suited for needs of your app. \n\n    apiDefinitionKey: api # Your API definition will be under this key in \"parameters\" section. \n```\n\n\n### First API endpoint\nNow let's say you want to make a REST endpoint creating channels, `[POST] /new-api/2.0/channels`\n\nYou need to define in `parameters.api` section in `config.neon`.\n\n\u003e **Both services and middlewares must be registered services in DI Container.**\n\n```yaml\nslimApi:\n    handlers:\n        notFound: App\\NotFoundHandler # Called when not route isn't matched by URL\n        notAllowed: App\\NotAllowedHandler # Called when route isn't matched by method\n        error: App\\ApiErrorHandler # Called when unhandled exception bubbles out\n\n    routes:\n        \"2.0\": # Version of your API\n            \"channels\": # Matched URL will be \"your-domain.org/2.0/channels\"\n                post:\n                    # This is service will be invoked to handle the request\n                    service: App\\CreateChannelAction\n                    \n                    # Here middleware stack is defined. It's evaluated from bottom to top. \n                    middlewares:\n                        - App\\SomeOtherMiddleware # last in row\n                        - App\\UsuallyRequestDataValidationMiddleware # second in row\n                        - App\\SomeAuthMiddleware # this one is called first \n\n    beforeRouteMiddlewares:\n        # this is called for each route, before route middlewares\n        - App\\SomeBeforeRouteMiddleware \n        \n    afterRouteMiddlewares:\n        # this is called for each route, after the route middlewares\n        - App\\SomeAfterRouteMiddleware\n\n    beforeRequestMiddlewares:\n        # this is called for each request, even when route does NOT exist (404 requests)\n        - App\\SomeBeforeRequestMiddleware\n```\n\nYou can also reference the named service by its name.\n\nSee `tests/SlimApplicationFactoryTest.php` and `tests/config.neon` for more examples.\n\n### Execution\nNow you can simply get `SlimApplicationFactory` class from your DI Container (or better autowire it), create app and run it.\n\n```php\n$factory = $container-\u003egetByType(SlimApplicationFactory::class);\n$factory-\u003ecreate()-\u003erun();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandembassy%2Fslim-nette-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandembassy%2Fslim-nette-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandembassy%2Fslim-nette-extension/lists"}