Hi there ๐ , I'm
-
๐คฏ I'm currently dedicating my time and energy to mastering JavaScript.
-
๐ฌ Ask me about PHP, Laravel, Vue.js, React, Next.js, SQL, Software Engineering
Simple and ready to use API response wrapper for Laravel.
License: MIT License
add error message api, api()->error()
Hello developer, I'm using your excellent package, but I have a issue with php 8 version, can you update your package to fix this problem?.
This is composer console error:
Problem 1
- Root composer.json requires obiefy/api-response ^0.9.5 -> satisfiable by obiefy/api-response[v0.9.5].
- obiefy/api-response v0.9.5 requires php ^7.3 -> your php version (8.0.5) does not satisfy that requirement.
Thanks!!
if the config('api.stringify')
is set to true response will be like:
{
"STATUS": "200",
"MESSAGE": "User Profile data",
"DATA": [
...
],
"DATACOUNT": 6
}
The expected response is:
{
"STATUS": "200",
"MESSAGE": "User Profile data",
"DATA": [
...
],
"DATACOUNT": "6"
}
@beauraines can you please submit PR for this one?
api-response/src/config/api.php
Line 31 in c74a9d6
Good for high-level configuration,
So the developer just configures new methods by just adding it to config files.
like:
'methods' => [
[
'code' => 444,
'method' => 'forbidden',
'message' => 'This is default message'
]
]
After that developer can access this throw helpers or facades
api()->forbidden()
Hi! I get this error when installing version 0.9.7
Problem 1
- Root composer.json requires obiefy/api-response ^0.9.7 -> satisfiable by obiefy/api-response[v0.9.7].
- obiefy/api-response v0.9.7 requires illuminate/support ^8.0|^7.0|^6.0|^5.5 -> found illuminate/support[v5.5.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require obiefy/api-response:*" to figure out if any version is installable, or "composer require obiefy/api-response:^2.1" if you know which you need.
Not compatible with Laravel10?
if you need to use api()->validation()
function you cannot pass specific message.
so it will be good to make message optional
I am having
Problem 1
- Installation request for obiefy/api-response ^0.9.1 -> satisfiable by obiefy/api-response[v0.9.1].
- Installation request for laravel/framework (locked at v8.10.0, required as ^8.0) -> satisfiable by laravel/framework[v8.10.0].
- Can only install one of: laravel/framework[8.x-dev, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.0.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.0.1, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.0.2, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.0.3, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.0.4, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.1.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.10.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.2.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.3.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.4.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.5.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.6.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.7.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.7.1, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.8.0, 5.7.x-dev].
- Can only install one of: laravel/framework[v8.9.0, 5.7.x-dev].
- Can only install one of: laravel/framework[5.7.x-dev, v8.10.0].
- Can only install one of: laravel/framework[5.7.x-dev, v8.10.0].
- Conclusion: install laravel/framework 5.7.x-dev
- Installation request for laravel/framework ^8.0 -> satisfiable by laravel/framework[8.x-dev, v8.0.0, v8.0.1, v8.0.2, v8.0.3, v8.0.4, v8.1.0, v8.10.0, v8.2.0, v8.3.0, v8.4.0, v8.5.0, v8.6.0, v8.7.0, v8.7.1, v8.8.0, v8.9.0].
How can I fix it?
I am trying to install it on Laravel 8.6 but i get:
Problem 1
- Installation request for obiefy/api-response ^0.9.1 -> satisfiable by obiefy/api-response[v0.9.1].
- Conclusion: remove laravel/framework v8.6.0
- Conclusion: don't install laravel/framework v8.6.0
Any idea if this a compatibility issue with the latest Laravel 8?
improve code docs and config file docs, and also read me file.
It seems that all of your API responses return a 200 OK http status header.
This means that any receiving front-end framework will receive conflicting status information in the event of a non-200 status (JSON object says "500 Internal Server Error", http header says "200 OK") and front-end libraries may fail to detect errors as the status header tells them everything's OK, even if the server has thrown an error.
It would be good if you could support and promote use of the JSON API specification, which is already an established format:
HTTP/1.1 422 Unprocesssable Entity
Content-Type: application/vnd.api+json
{
"errors": [
{
"source": { "pointer": "" },
"detail": "Missing `data` Member at document's top level."
}
]
}
I thinking about something like this.
api()->response($status, $message, $data, $extraData);
at the current version this will not work, because response()
method parameters are fixed to three (status, message and data).
i follow all steps to installation and setting up. finally step 4; I run the command
php artisan vendor:publish --tag=api-response
it give me error :
In ProviderRepository.php line 208:
Class 'Obiefy\API\APIServiceProvider' not found
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.