PHPackages                             getpop/api - 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. [Database &amp; ORM](/categories/database)
4. /
5. getpop/api

ActiveLibrary[Database &amp; ORM](/categories/database)

getpop/api
==========

Component-based API

18.0.1(1mo ago)25.8k1GPL-2.0-or-laterPHPPHP ^8.1CI failing

Since Jan 25Pushed 2w ago2 watchersCompare

[ Source](https://github.com/PoP-PoPAPI/api)[ Packagist](https://packagist.org/packages/getpop/api)[ Docs](https://github.com/PoP-PoPAPI/api)[ RSS](/packages/getpop-api/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (21)Versions (154)Used By (1)

PoP API
=======

[](#pop-api)

Convert the application into a powerful API. Install the [Gato GraphQL](https://github.com/PoP-PoPAPI/api-graphql) package to convert it into a GraphQL server, and the [REST API](https://github.com/PoP-PoPAPI/api-rest) package to enable adding REST endpoints.

Install
-------

[](#install)

### Installing a fully-working API

[](#installing-a-fully-working-api)

Follow the instructions under [Bootstrap a PoP API for WordPress](https://github.com/leoloso/PoP-API-WP) (even though CMS-agnostic, only the WordPress adapters have been presently implemented).

### Installing this library

[](#installing-this-library)

Via Composer

```
composer require pop-api/api
```

#### Enable pretty permalinks

[](#enable-pretty-permalinks)

##### Apache

[](#apache)

Add the following code in the `.htaccess` file to enable API endpoint `/api/`:

```

RewriteEngine On
RewriteBase /

# Rewrite from /some-url/api/ to /some-url/?scheme=api
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)/api/?$ /$1/?scheme=api [L,P,QSA]

# Rewrite from api/ to /?scheme=api
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^api/?$ /?scheme=api [L,P,QSA]

```

To add pretty API endpoints for the extensions (GraphQL =&gt; `/api/graphql/`), REST =&gt; `/api/rest/`), add the following code to file `.htaccess`:

```

RewriteEngine On
RewriteBase /

# a. Resource endpoints
# 1 and 2. GraphQL or REST: Rewrite from /some-url/api/(graphql|rest)/ to /some-url/?scheme=api&datastructure=(graphql|rest)
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)/api/(graphql|rest)/?$ /$1/?scheme=api&datastructure=$2 [L,P,QSA]

# b. Homepage single endpoint (root)
# 1 and 2. GraphQL or REST: Rewrite from api/(graphql|rest)/ to /?scheme=api&datastructure=(graphql|rest)
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^api/(graphql|rest)/?$ /?scheme=api&datastructure=$1 [L,P,QSA]

```

##### Nginx

[](#nginx)

Add the following code in the Nginx configuration's `server` entry, to enable API endpoint `/api/`. Please notice that the resolver below is the one for Docker; replace this value for your environment.

```
location ~ ^(.*)/api/?$ {
    # Resolver for Docker. Change to your own
    resolver 127.0.0.11 [::1];
    # If adding $args and it's empty, it does a redirect from /api/ to ?scheme=api.
    # Then, add $args only if not empty
    set $redirect_uri "$scheme://$server_name$1/?scheme=api";
    if ($args) {
        set $redirect_uri "$scheme://$server_name$1/?$args&scheme=api";
    }
    proxy_pass $redirect_uri;
}
```

To add pretty API endpoints for the extensions (GraphQL =&gt; `/api/graphql/`), REST =&gt; `/api/rest/`), add the following code:

```
location ~ ^(.*)/api/(rest|graphql)/?$ {
    # Resolver for Docker. Change to your own
    resolver 127.0.0.11 [::1];
    set $redirect_uri "$scheme://$server_name$1/?scheme=api&datastructure=$2";
    if ($args) {
        set $redirect_uri "$scheme://$server_name$1/?$args&scheme=api&datastructure=$2";
    }
    proxy_pass $redirect_uri;
}
```

Development
-----------

[](#development)

The source code is hosted on the [GatoGraphQL monorepo](https://github.com/GatoGraphQL/GatoGraphQL), under [`API/packages/api`](https://github.com/GatoGraphQL/GatoGraphQL/tree/master/layers/API/packages/api).

Usage
-----

[](#usage)

Initialize the component:

```
\PoP\Root\App::stockAndInitializeModuleClasses([([
    \PoPAPI\API\Module::class,
]);
```

> **Note:**
> To enable GraphQL and/or REST endpoints, the corresponding package must be installed: [GraphQL package](https://github.com/PoP-PoPAPI/api-graphql), [REST package](https://github.com/PoP-PoPAPI/api-rest)

Standards
---------

[](#standards)

[PSR-1](https://www.php-fig.org/psr/psr-1), [PSR-4](https://www.php-fig.org/psr/psr-4) and [PSR-12](https://www.php-fig.org/psr/psr-12).

To check the coding standards via [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer), run:

```
composer check-style
```

To automatically fix issues, run:

```
composer fix-style
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

To execute [PHPUnit](https://phpunit.de/), run:

```
composer test
```

Static Analysis
---------------

[](#static-analysis)

To execute [PHPStan](https://github.com/phpstan/phpstan), run:

```
composer analyse
```

Report issues
-------------

[](#report-issues)

To report a bug or request a new feature please do it on the [GatoGraphQL monorepo issue tracker](https://github.com/GatoGraphQL/GatoGraphQL/issues).

Contributing
------------

[](#contributing)

We welcome contributions for this package on the [GatoGraphQL monorepo](https://github.com/GatoGraphQL/GatoGraphQL) (where the source code for this package is hosted).

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Leonardo Losoviz](https://github.com/leoloso)
- [All Contributors](../../../../../../contributors)

License
-------

[](#license)

GNU General Public License v2 (or later). Please see [License File](LICENSE.md) for more information.

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance95

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% 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 ~12 days

Total

153

Last Release

33d ago

Major Versions

13.2.0 → 14.0.02025-09-09

14.0.4 → 15.0.02025-09-23

15.3.0 → 16.0.02026-01-12

16.0.3 → 17.0.02026-03-03

17.1.2 → 18.0.02026-05-20

PHP version history (3 changes)0.7.6PHP ^7.4|^8.0

0.8.1PHP ^8.0

0.9.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1981996?v=4)[Leonardo Losoviz](/maintainers/leoloso)[@leoloso](https://github.com/leoloso)

![](https://www.gravatar.com/avatar/d5a0a064bae63a335ddd796bb69ab38e1d01420d14bfcc8e3d4e1550922ac60b?d=identicon)[getpop](/maintainers/getpop)

---

Top Contributors

[![leoloso](https://avatars.githubusercontent.com/u/1981996?v=4)](https://github.com/leoloso "leoloso (1268 commits)")

---

Tags

apidatadatabasegraphqlphppoprestphpapigraphqlGatoGatoGraphQL

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/getpop-api/health.svg)

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

PHPackages © 2026

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