PHPackages                             lacockj/phi - 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. lacockj/phi

ActiveLibrary[Framework](/categories/framework)

lacockj/phi
===========

A fast, easy-to-use micro-framework balancing speed, convenience, and security.

1.2.0(2y ago)05971[1 PRs](https://github.com/lacockj/phi/pulls)GPL-3.0-or-laterPHPPHP ^7 || ^8CI failing

Since Jan 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/lacockj/phi)[ Packagist](https://packagist.org/packages/lacockj/phi)[ RSS](/packages/lacockj-phi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (15)Used By (0)

[![Build Status](https://camo.githubusercontent.com/f7806a9dfa01ee23c4ba64abff1cb0a13ccd18984bdf68400e22e39f5ceeef53/68747470733a2f2f7472617669732d63692e6f72672f6c61636f636b6a2f7068692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lacockj/phi)

Phi
===

[](#phi)

Phi is a fast, easy-to-use micro-framework for PHP that endeavors to be the perfect balance between the *speed* of core PHP functions, the *convenience* of class methods, and the *security* of coding best-practices.

Phi includes handy methods for

- Request routing
- Parameterized database queries
- HTTP authentication
- Automatic response data formatting

Read the full documentation on the [Phi Wiki](https://github.com/lacockj/phi/wiki)

---

Request Routing
---------------

[](#request-routing)

Have nice, clean URLs!

Turn this: `/api.php?type=user&id=12345`

Into this: `/users/12345`

Clean URLs look better for webpage addresses, and are easier to use and understand for APIs. Phi can extract parameters from the URL for use in your code, like the user ID in the example above.

You create a list of URL patterns and request methods, and map them to whatever function or class method you want to handle the request. When a request matches a listed pattern, the handler function is called, receiving the URL parameters and input data. Input data could be GET query parameters, POST form data, or php://input.

```
/users         [POST]  = Users->createNewUser
/users/@userID [GET]   = Users->getUserByID
/users/@userID [PATCH] = Users->updateUser

```

Phi automatically responds to requests that don't match a URL pattern with the appropriate 404 "Not Found" status code. Similarly, an unexpected request method automatically gets a 405 "Method Not Allowed" status code and the `Allow:` response header with a list of the methods you do have in the list, in accordance with [RFC 2616](https://www.w3.org/Protocols/rfc2616/rfc2616.html).

---

Response Formatting
-------------------

[](#response-formatting)

Provide more context to your script's output. In one line of code, you can set the status code, status text, content type, and output your data in the selected format.

```
if ( $myDataArray ) {
  $phi->response->json( $myDataArray );  // Defaults to status 200 "OK"
} else {
  $phi->response->no_content( 204, "No data for the selected resource" );  // Custom status text
}

```

Using the headers and status codes makes it easier for your API's consumers to know when a request succeded or failed in a standarized way, and handle the response appropriately. All this information is already part of the [HTTP definition](https://www.w3.org/Protocols/rfc2616/rfc2616.html), why not use it?

---

Database Queries
----------------

[](#database-queries)

Databases are probably the most useful, and at the same time most troublesome tools in your web service. There is a constant struggle between making each request as fast as possible, and as secure as possible.

The number one best thing you can do to secure your database is use [parameterized queries](https://php.net/manual/en/mysqli.prepare.php). But this normally requires a five step process to prepare the query, bind the query parameters, execute the query, bind the result variables, and then fetch and use the results.

With Phi, you can execute a parameterized database query in one line of code. Better still, you get back a result you can iterate like an array.

```
$cities = $phi->db->pq( 'SELECT * FROM `Cities` WHERE `population` > ?', $userInputPopulation );
foreach ( $cities as $city ) {
  ...
}

```

Impact to the script's speed is minimal; the results are not all loaded into memory at once but as they are accessed, which is especially useful for very large result sets. There is no loss of security using Phi's convenient query method, and it greatly improves the code readability.

---

Testing
-------

[](#testing)

```
./vendor/bin/phpunit tests

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 81.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~131 days

Recently: every ~316 days

Total

11

Last Release

1007d ago

PHP version history (5 changes)v1.0-alphaPHP ^5.6

v1.0.1PHP ^5.6 || ^7.0

1.0.2PHP ^5.6 || ^7

1.1.8PHP ^5.6 || ^7 || ^8

1.2.0PHP ^7 || ^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b66d18657b5687354cd08320d65936501f3d725a351e717e33a9ca949bfd061?d=identicon)[lacockj](/maintainers/lacockj)

---

Top Contributors

[![lacockj](https://avatars.githubusercontent.com/u/13771445?v=4)](https://github.com/lacockj "lacockj (95 commits)")[![brianoflan](https://avatars.githubusercontent.com/u/1920395?v=4)](https://github.com/brianoflan "brianoflan (22 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lacockj-phi/health.svg)

```
[![Health](https://phpackages.com/badges/lacockj-phi/health.svg)](https://phpackages.com/packages/lacockj-phi)
```

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
