PHPackages                             caendesilva/pikoserve - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. caendesilva/pikoserve

ActiveLibrary[Framework](/categories/framework)

caendesilva/pikoserve
=====================

A truly tiny framework for PHP microservices

v1.1.0(4y ago)011MITPHP

Since Apr 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/caendesilva/pikoserve)[ Packagist](https://packagist.org/packages/caendesilva/pikoserve)[ RSS](/packages/caendesilva-pikoserve/feed)WikiDiscussions master Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (0)

🍦 Pikoserve - A truly tiny framework for PHP microservices
==========================================================

[](#-pikoserve---a-truly-tiny-framework-for-php-microservices)

 [ ![License MIT](https://camo.githubusercontent.com/b2762f643d32b3f0bc9d5ccb98ac55303e798ed2be382faeb0fb2408d2c7913e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f687964657068702f68796465) ](https://github.com/caendesilva/pikoserve/blob/master/LICENSE.md) [ ![Class Size](https://camo.githubusercontent.com/ab35e93855ab5c8a0f825c2b08dceb9df09d074b5fe3519a79b437cdbf947969/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73697a652f6361656e646573696c76612f70696b6f73657276652f50696b6f2e706870) ](https://github.com/caendesilva/pikoserve/blob/master/Piko.php) [![StyleCI Status](https://camo.githubusercontent.com/a06ba4dd64110b49f986f23234ed36208ef78b20efdbd14d532933097afe707c/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3438343139323831362f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/484192816?branch=master)

About
-----

[](#about)

Pico is a unit prefix often used for something extremely tiny. Which is just what Pikoserve is! While it is designed for writing **microservices in PHP** calling it a microframework seems excessive.

Pikoserve came to be in this tweet:

At its core, Pikoserve is a starter template for creating tiny stateless API services and is essentially a wrapper for writing and reading JSON responses and sending the proper headers all within a single tiny class.

Installation
------------

[](#installation)

Since it is so lightweight you can get started by just downloading the Piko.php file (or copying and pasting it), then reference it in a PHP file (usually index.php). If you want you can even use the Piko.php file as your index.php code, just place your own code under the Piko class. Though I prefer to keep it separate to reduce clutter.

To get started quickly, you can use Composer or Git.

```
composer create-project caendesilva/pikoserve
git clone https://github.com/caendesilva/pikoserve
```

Usage
-----

[](#usage)

Create an index.php file containing the Main class. Require the Piko.php file, and write your code in the Main class. Then call Piko::boot() with the Main class. Piko will then send the headers and execute the handle method and return a JSON Response.

Setting up a starter project
----------------------------

[](#setting-up-a-starter-project)

The only file you need is the Piko.php file, but to get started quickly you can use the starter project in the repo.

You can also use Composer to create a new Piko project. It is not available as a package, since if you are writing something that will be dependent on several packages you will probably need something more sophisticated than Piko anyway.

```
# Get started with Composer
composer create-project caendesilva/pikoserve

# Get started with Git
git clone https://github.com/caendesilva/pikoserve
```

This will set you up with the Piko.php file which contains the Piko class, and an index.php file that references it. Speaking of, let's take a look at what it looks like.

### Hello World Example

[](#hello-world-example)

> This is the index.php file that is shipped with Piko but is shown here again to break down how Piko works.

```
