Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
PHP - Need API w/ Authentication
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="RastaLulz" data-source="post: 465963" data-attributes="member: 1"><p>Like [USER=15674]@BIOS[/USER] mentioned, you'd be doing your self a service to use a framework like <a href="https://www.slimframework.com/" target="_blank">Slim</a> or <a href="https://lumen.laravel.com/" target="_blank">Lumen</a> (I'd argue that you should just use <a href="https://laravel.com/" target="_blank">Laravel</a> instead of Lumen). Or even using <a href="https://getcomposer.org/" target="_blank">composer</a> to pull in widely used <a href="https://packagist.org/" target="_blank">packages</a>, instead of trying to reinvent the wheel. I'd also recommend following <a href="https://www.php-fig.org/psr/" target="_blank">PSR</a>'s, especially <a href="https://www.php-fig.org/psr/psr-12/" target="_blank">PSR-12</a> and <a href="https://www.php-fig.org/psr/psr-1/" target="_blank">PSR-1</a>, so that when you do share code, it's formatted in a standard way.</p><p></p><p>As for the code you provided:</p><ul> <li data-xf-list-type="ul">I'd be more interested in how you interact with the API. Explain what the endpoints will be, and how you'll handle auth (as if you're providing documentation to your client).</li> <li data-xf-list-type="ul">An API should be consistent in what content-type it returns. By that I mean, it should always return JSON (or XML, CSV, etc, but be consistent), so that the API consumer has a general expectation of how to parse the response. So when you return an error, that should also be consistent; it appears that you've done this to extent, but not when there's a >400 status code.</li> <li data-xf-list-type="ul">Instead of returning [ICODE]No Volunteers Found[/ICODE], simply return an empty array.</li> </ul></blockquote><p></p>
[QUOTE="RastaLulz, post: 465963, member: 1"] Like [USER=15674]@BIOS[/USER] mentioned, you'd be doing your self a service to use a framework like [URL='https://www.slimframework.com/']Slim[/URL] or [URL='https://lumen.laravel.com/']Lumen[/URL] (I'd argue that you should just use [URL='https://laravel.com/']Laravel[/URL] instead of Lumen). Or even using [URL='https://getcomposer.org/']composer[/URL] to pull in widely used [URL='https://packagist.org/']packages[/URL], instead of trying to reinvent the wheel. I'd also recommend following [URL='https://www.php-fig.org/psr/']PSR[/URL]'s, especially [URL='https://www.php-fig.org/psr/psr-12/']PSR-12[/URL] and [URL='https://www.php-fig.org/psr/psr-1/']PSR-1[/URL], so that when you do share code, it's formatted in a standard way. As for the code you provided: [LIST] [*]I'd be more interested in how you interact with the API. Explain what the endpoints will be, and how you'll handle auth (as if you're providing documentation to your client). [*]An API should be consistent in what content-type it returns. By that I mean, it should always return JSON (or XML, CSV, etc, but be consistent), so that the API consumer has a general expectation of how to parse the response. So when you return an error, that should also be consistent; it appears that you've done this to extent, but not when there's a >400 status code. [*]Instead of returning [ICODE]No Volunteers Found[/ICODE], simply return an empty array. [/LIST] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
PHP - Need API w/ Authentication
Top