https://github.com/luizeof/php-rest-api
Easy way to create a PHP Rest API with Basic Authentication
https://github.com/luizeof/php-rest-api
api auth http php rest
Last synced: about 1 month ago
JSON representation
Easy way to create a PHP Rest API with Basic Authentication
- Host: GitHub
- URL: https://github.com/luizeof/php-rest-api
- Owner: luizeof
- License: gpl-3.0
- Created: 2020-01-02T00:43:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-02T15:27:27.000Z (over 6 years ago)
- Last Synced: 2025-12-26T20:11:39.641Z (6 months ago)
- Topics: api, auth, http, php, rest
- Language: PHP
- Homepage: https://packagist.org/packages/luizeof/php-rest-api
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-rest-api
Easy way to create a PHP REST API with ```Basic Authentication```
## Installing
To install `luizeof/php-rest-api`, run this command on your terminal:
```bash
composer require luizeof/php-rest-api
```
## Importing
Import `autoload` on your project:
```php
require __DIR__ . '/vendor/autoload.php';
```
## Sample Usage
```php
validate_auth( function() use ($api) {
if ($api->get_username() == "luiz") {
return true;
} else {
return false;
}
}); // validate_auth()
$arr = array('id' => 1, 'title' => "Exemplo", 'date' => "01/01/2020", 'tags'=> array("php","docker","flutter"), 'author' => "luizeof");
$api->array_to_json($arr);
$api->request_success();
} catch (Throwable $t) {
$api->request_error($t);
} catch (Exception $e) {
$api->request_error($e);
} finally {
unset($api);
}
?>
```