PHPackages                             phpcoreapi/phpcoreapi - 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. [API Development](/categories/api)
4. /
5. phpcoreapi/phpcoreapi

ActiveLibrary[API Development](/categories/api)

phpcoreapi/phpcoreapi
=====================

PHP Core API CLI to create PHP API projects with routing, controllers, and database setup

10.0.1(3mo ago)015MITPHPPHP &gt;=7.4

Since Feb 7Pushed 3mo agoCompare

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

READMEChangelogDependenciesVersions (12)Used By (0)

PHPCoreAPI Project Setup
========================

[](#phpcoreapi-project-setup)

1. Web Server Configuration
---------------------------

[](#1-web-server-configuration)

- Set your web server root to the 'public' folder of the project. Example paths:

    - Apache: DocumentRoot -&gt; /path/to/myapi/public
    - Nginx: root -&gt; /path/to/myapi/public
- URL rewriting is required for routing to work properly.

**Apache (.htaccess example):**

```

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [QSA,L]

```

**Nginx (server block example):**

```
server {
    listen 80;
    server_name yourdomain.com;
    root /path/to/myapi/public;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # adjust PHP version
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }
}

```

- Restart the server after changes.
- Visit your project URL to confirm it works.

2. Database Configuration
-------------------------

[](#2-database-configuration)

- File: `app/Core/Database.php`
- Update variables with your database credentials:

```
$dbHost = '127.0.0.1';
$dbUser = 'root';
$dbPass = '';
$dbName = 'mydatabase';
```

- Controllers automatically get a private MySQLi connection:

```
$this->_db = Database::connect();
```

3. Routing
----------

[](#3-routing)

- All routes are in `app/Routes/web.php`

**Independent routes:**

```
$router->get('/status', [HealthController::class, 'index']);
```

**Base route groups:**

```
$router->group('/api', function($r){
    $r->get('/health', [HealthController::class, 'index']);
    $r->post('/user/create', [UserController::class, 'store']);
});
```

- You can have multiple base groups like `/auth` or `/admin`.

4. Controllers
--------------

[](#4-controllers)

- Create a controller:

```
phpcoreapi make:controller UserController
```

- Create controller in subfolder:

```
phpcoreapi make:controller Auth/UserController
```

- Request helpers:

    - `Request::JsonBody()` → raw JSON string
    - `Request::JsonData()` → decoded JSON array
    - `Request::GetData()` → $\_GET
    - `Request::PostData()` → $\_POST
- Example:

```
$data = Request::JsonData();
$name = $data['name'] ?? null;
$this->_db->query("INSERT INTO users (name) VALUES ('$name')");
```

5. CLI Commands
---------------

[](#5-cli-commands)

- **Create project:** `phpcoreapi create-project myapi`
- **Serve server:** `phpcoreapi serve` (default 8080) or `phpcoreapi serve 2303`
- **Build production:** `phpcoreapi build`
- **Make controller:** `phpcoreapi make:controller UserController`
- **Add composer library:** `phpcoreapi add guzzlehttp/guzzle`

6. Local Development
--------------------

[](#6-local-development)

- Start server: `phpcoreapi serve`
- Open browser: `http://localhost:8080`

7. Production Build
-------------------

[](#7-production-build)

- Run: `phpcoreapi build`
- Output: `/dist`
- Install composer optimized: `composer install --no-dev --optimize-autoloader`
- Set web root to `/dist/public`

8. Adding Composer Libraries
----------------------------

[](#8-adding-composer-libraries)

- Example: `phpcoreapi add guzzlehttp/guzzle`

9. Example API Requests
-----------------------

[](#9-example-api-requests)

**JSON POST:**

```
curl -X POST http://localhost:8080/user/create \
  -H "Content-Type: application/json" \
  -d '{"name":"John","email":"john@example.com"}'
```

**Form POST:**

```
curl -X POST http://localhost:8080/user/create -d "name=John&email=john@example.com"
```

**GET:**

```
curl http://localhost:8080/status
```

10. Notes
---------

[](#10-notes)

- Always keep web root pointing to 'public'
- Controllers use Request &amp; Database helpers
- Edit `web.php` for routing only

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance81

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.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 ~0 days

Total

11

Last Release

98d ago

Major Versions

5.0.0 → 6.0.02026-02-07

6.0.0 → 7.0.02026-02-07

7.0.0 → 8.0.02026-02-09

8.0.0 → 9.0.02026-02-09

9.0.0 → 10.0.02026-02-09

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

5.0.0PHP &gt;=7.4

### Community

Maintainers

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

---

Top Contributors

[![teamxdindia](https://avatars.githubusercontent.com/u/269041277?v=4)](https://github.com/teamxdindia "teamxdindia (15 commits)")[![phpcoreapi](https://avatars.githubusercontent.com/u/260090200?v=4)](https://github.com/phpcoreapi "phpcoreapi (2 commits)")

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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