Pionia Framework is a PHP framework for building RESTFUL APIs. It is a lightweight framework that is easy to use and easy to understand.
It runs on top of ✨ Moonlight ✨ architecture.
composer create-project pionia/pionia-app project_name
Please remember to replace project_name
with your project name
|-authentications
|-bootstrap
|----application.php
|----routes.php
|-commands
|-environment
|----.env
|----settings.ini
|-middlewares
|-public
|-- .htaccess
|-- index.php
services
static
|-- favicon.png
|-- pionia_logo.webp
|-- favicon.ico
|-- bootstrap.min.css
storage
|-- cache
|-- logs
|-- scripts
vendor
.gitignore
composer.json
composer.lock
pionia
README.md
- 📂 authentication:- This is where authentication backends should reside. These are the strategies that the app will use to authenticate users to the app context.
- 📂 middlewares:- This is where all request middlewares reside. These are the classes that run on every request and every response.
- 📂 services:- This is where our actual business logic resides.
- 📂 commands:- This is where all our commandline commands reside.
- 📂 environment:- This is where all our environment settings reside.
- 📂 storage:- This is where all our storage files reside.
- 📂 static:- This is where all our static files reside. Default files found here should never be deleted.
- 📂 vendor:- This is where all our composer dependencies reside.
- 📄 .gitignore:- This is where we specify files that should not be tracked by git.
- 📄 composer.json:- This is where we specify all our composer dependencies.
- 📄 composer.lock:- This is where we specify all our composer dependencies.
- 📄 pionia:- This is our commandline helper. For every command, we call this file.
- 📂 public:- This is where our public files reside. This is where our entry file resides.
- 📄 switches:- This is where our main app switch resides. This is where we register all our services.
- 📄 pionia:- This is our commandline helper. For every command, we call this file.
- 📄 README.md:- This is our documentation file. This is where we document our project.
- 📂 bootstrap:- This is where our application bootstrapping files reside. This is where we register all our routes.
After installation, just run the following to start the server
php pionia serve # http://localhost:8000
By default, the server will run on port 8000, to change that, run the following
php pionia serve --port 8080 # http://localhost:8080
Your endpoint is now running on http://localhost:8080/api/v1/
You can follow along the documentation but its under active development.
You can also run php pionia
to get a list of all available commands.
If you're making any http requests from your frontend, we recommend using the jet-fetch
library.
However, other framework-specific packages are still okay like the z-fetch
for z-js
and axios
.
In the root of your project, run :-
NPM
npm install jet-fetch
YARN
yarn add jet-fetch
Then use the moonlightRequest
method of the package to query any moonlight-powered backend.
import { Jet } from 'jet-fetch';
const jet = new Jet({
baseUrl: 'http://localhost:8000/api/',
});
// unauthenticated requests
const res = await jet.moonlightRequest(
{
service: 'yourService',
action: 'yourAction',
...anyOtherData
}, 'v2/');
// for jwt-authenticated requests
const res = await jet.secureMoonlightRequest(
{
service: 'yourService',
action: 'yourAction',
...anyOtherData
}, 'v2/');
For details about jet-fetch
, follow the readme guide provided here.
All forms of contributions are welcome from documentation, coding, community development and many more.