Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discussion] Status Code as Constants #2310

Closed
Raistlfiren opened this issue Sep 29, 2017 · 5 comments
Closed

[Discussion] Status Code as Constants #2310

Raistlfiren opened this issue Sep 29, 2017 · 5 comments

Comments

@Raistlfiren
Copy link

Raistlfiren commented Sep 29, 2017

Hey,

I just wanted to bring up a discussion for later releases on adding the status codes as constants to the Response class. Similarly to http://api.symfony.com/3.4/Symfony/Component/HttpFoundation/Response.html

I feel like it is much more beneficial coding using constants instead of status code of say 422 or 400. For example, users can now use the constants in their code like Response::HTTP_UNPROCESSABLE_ENTITY or Response::HTTP_BAD_REQUEST.

Thoughts?

Thanks for your time and consideration.

@geggleto
Copy link
Member

We already have this baked in.

https://github.com/slimphp/Slim/blob/3.x/Slim/Http/Response.php#L48-L118

I don't see the problem it solves. If you don't know the status code you wish to use then you need to know the name it uses... which often times is not really a name that you think of... example 418 => 'I\'m a teapot',

@mahagr
Copy link

mahagr commented Oct 18, 2017

To me, error codes are more clear than the titles of the errors. So no, it will only make things worse.

@akrabat
Copy link
Member

akrabat commented Oct 18, 2017

I'm not against it. I would use STATUS_XYZ rather than HTTP_XYZ personally, though.

@geggleto
Copy link
Member

@akrabat Nothing can really be done on 3.x... but this should be raised on slimphp/http

@geggleto
Copy link
Member

Going to close this here, it's open on Http and we can change the constants in 4.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants