Comments (2)
Hi, @raizdev! You need PSR-(1)7 implementation...
declare(strict_types=1);
namespace Cosmic\App\Controllers\Home;
use Sunrise\Http\Router\Annotation as Mapping;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
class Index
{
#[Mapping\Route('index', path: '/')]
public function index(Request $request): Response
{
return (new ResponseFactory)->createResponse(200);
}
}
from http-router.
Hi, @raizdev! You need PSR-(1)7 implementation...
declare(strict_types=1); namespace Cosmic\App\Controllers\Home; use Sunrise\Http\Router\Annotation as Mapping; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ResponseInterface as Response; class Index { #[Mapping\Route('index', path: '/')] public function index(Request $request): Response { return (new ResponseFactory)->createResponse(200); } }
Thank you for your explantation!
I was wondering if it is possible to add ResponseFactory in a container to get them through the function. Using (new ResponseFactory)-> feels codingwise not correct
from http-router.
Related Issues (20)
- ServerRequestFactory helper without inherit it as an argument
- How to response Json?
- Containers
- Generating JSON schemas for the request parameters/body validation HOT 2
- chubbyphp-framework released with http-router 2 support
- Don't create the QueueableRequestHandler if the router/route doesn't contain middleware
- MethodNotAllowed is thrown when not needed and vice versa HOT 2
- PHP 8 support HOT 2
- PHP8 attributes support HOT 1
- Creating custom named attributes for routes
- Flexible request handler definition for route HOT 5
- Create a command for the list of routes
- Create the router builder
- Create a new Middleware annotation for route declaration in one line HOT 1
- Serialization of ReflectionClass is not allowed
- Dependency Dashboard
- Short version of URI generation
- Provide the changelog with the next version
- Gets a route holder HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-router.