anwarachilles/nirvana-native-php

Lightweight & simple PHP Rest Http

dev-main 2024-04-14 04:41 UTC

This package is auto-updated.

Last update: 2024-06-14 05:07:12 UTC


README

Lightweight tool for building simple Rest HTTP/API in PHP programming language environment

version - Beta

Example Use

Install with composer

composer require anwarachilles/nirvana-native-php

PHP structure

Create an index.php file, then setup environment & rest, like the example below.

Nirvana::environment([
  'Configure'=> [
    'development'=> true,
    'baseurl'=> 'http://localhost/<yourproject>/',
  ]
]);


Nirvana::rest('GET', 'demo', function() {
  return [
    'name'=> Nirvana::method('name'),
    'code'=> Nirvana::method('code'),
  ];
});

API Reference

Environment configure

Properties Type Description
development string Optional. will return response with development dataset
basedir __DIR__ Required set default baseurl from the project
baseurl string Required set default baseurl from the project

Nirvana inside Rest

Method & Properties Type Description
method string return data on method requested.
load string load another Rest.
data string (Under Development)
store name get data from store can do CRUD

Nirvana outside Rest

Method & Properties Type Description
ifNotFound void set default 404 not found if request not have Rest.
store name, data array set data to store.

Special handler store

Method & Properties Type Description
set array insert/create data to store
get idorvoid view/load data from store
put id, array update/load data from store
del id delete/remove data from store
find field, valueorvoid view data from store with specified field and value, or only field

portfolio