PHPackages                             jc\_as/crud-php-pure - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jc\_as/crud-php-pure

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jc\_as/crud-php-pure
====================

Crud con php puro y javascript puro

v1.0.4(3mo ago)01MITPHPPHP &gt;=8.1

Since Mar 5Pushed 3mo agoCompare

[ Source](https://github.com/juliocf94/crud-php-pure)[ Packagist](https://packagist.org/packages/jc_as/crud-php-pure)[ RSS](/packages/jc-as-crud-php-pure/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

CRUD-PHP-Pure
=============

[](#crud-php-pure)

API REST construida en PHP puro sin frameworks, aplicando principios de arquitectura limpia: separación de responsabilidades, middleware pipeline, auto-discovery de rutas y contenedor de dependencias manual.

---

Requisitos
----------

[](#requisitos)

- PHP 8.1+
- Composer
- Docker (opcional)

---

Instalación
-----------

[](#instalación)

**Proyecto nuevo desde cero**

```
composer init
```

**Proyecto clonado desde GitHub**

```
composer install
```

**Con Docker**

```
docker-compose up -d
```

Copiar el archivo de entorno y configurar variables:

```
cp .env.example .env
```

---

Estructura del proyecto
-----------------------

[](#estructura-del-proyecto)

```
crud-php-pure/
│
├── public/
│   └── index.php                    # Front Controller — punto de entrada único
│
├── bootstrap/
│   └── app.php                      # Ensambla la app: .env, middleware y rutas
│
├── app/
│   ├── Core/
│   │   ├── Application.php          # Orquestador principal
│   │   ├── Database.php             # Conexión PDO
│   │   ├── Router.php               # Enrutador HTTP
│   │   ├── Response.php             # Helper de respuestas JSON
│   │   ├── ExceptionHandler.php     # Manejador global de errores
│   │   │
│   │   ├── Exceptions/
│   │   │   ├── HttpException.php
│   │   │   ├── NotFoundException.php
│   │   │   ├── ValidationException.php
│   │   │   └── UnauthorizedException.php
│   │   │
│   │   └── Middleware/
│   │       ├── MiddlewareInterface.php
│   │       ├── MiddlewarePipeline.php
│   │       ├── CorsMiddleware.php
│   │       ├── JsonBodyMiddleware.php
│   │       └── AuthMiddleware.php
│   │
│   ├── Controllers/
│   │   └── ClientController.php
│   │
│   └── Models/
│       └── ClientRepository.php
│
├── config/
│   └── database.php                 # Configuración de base de datos
│
├── routes/
│   ├── priority/                    # Rutas de carga garantizada (health checks, etc.)
│   │   └── health.php
│   │
│   └── modules/                     # Auto-discovery: cada módulo en su archivo
│       └── clients.php
│
├── storage/
│   └── logs/                        # Logs de la aplicación
│
├── .env
├── composer.json
└── docker-compose.yml

```

---

Flujo de la aplicación
----------------------

[](#flujo-de-la-aplicación)

```
public/index.php
      │
      ▼
bootstrap/app.php              ← carga .env, middleware y rutas
      │
      ├── routes/priority/     ← carga manual (orden garantizado)
      │   └── health.php
      │
      └── routes/modules/      ← auto-discovery (todos los .php)
          └── clients.php
      │
      ▼
App\Core\Application           ← orquesta todo
      │
      ▼
MiddlewarePipeline → Router::dispatch()

```

---

Sistema de rutas
----------------

[](#sistema-de-rutas)

Las rutas están separadas en dos categorías para garantizar flexibilidad y orden de carga:

**`routes/priority/`** — Carga manual y ordenada. Para rutas que deben registrarse primero: health checks, status, autenticación.

**`routes/modules/`** — Auto-discovery. Cualquier archivo `.php` en esta carpeta se carga automáticamente. Para añadir un módulo nuevo basta con crear el archivo; no es necesario modificar ningún otro fichero.

```
// routes/modules/clients.php
$router->get('/api/clients',          fn()    => $controller->index());
$router->post('/api/clients',         fn()    => $controller->store());
$router->get('/api/clients/{id}',     fn($id) => $controller->show($id));
$router->put('/api/clients/{id}',     fn($id) => $controller->update($id));
$router->delete('/api/clients/{id}',  fn($id) => $controller->destroy($id));
```

---

Endpoints disponibles
---------------------

[](#endpoints-disponibles)

### Clients

[](#clients)

MétodoEndpointDescripción`GET``/api/clients`Listar todos los clientes`POST``/api/clients`Crear un cliente`GET``/api/clients/{id}`Obtener un cliente`PUT``/api/clients/{id}`Actualizar un cliente`DELETE``/api/clients/{id}`Eliminar un cliente### Sistema

[](#sistema)

MétodoEndpointDescripción`GET``/health`Estado de la API---

Variables de entorno
--------------------

[](#variables-de-entorno)

```
APP_ENV=local

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=crud_php
DB_USERNAME=root
DB_PASSWORD=secret
```

---

Añadir un nuevo módulo
----------------------

[](#añadir-un-nuevo-módulo)

1. Crear el controlador en `app/Controllers/`
2. Crear el repositorio en `app/Models/`
3. Crear el archivo de rutas en `routes/modules/nombremodulo.php`

`index.php` y `bootstrap/app.php` **no requieren ninguna modificación**.

---

Middleware
----------

[](#middleware)

MiddlewareDescripción`CorsMiddleware`Cabeceras CORS para peticiones cross-origin`JsonBodyMiddleware`Parsea el body JSON entrante`AuthMiddleware`Validación de token (desactivado por defecto)Para activar `AuthMiddleware`, descomentar en `bootstrap/app.php`:

```
$app->addMiddleware(new AuthMiddleware());
```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance79

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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 ~1 days

Total

4

Last Release

108d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/06efec1c6f030faac7878094f26fef2d7bffa800bea0a9a0800f4f141dbb01a6?d=identicon)[Ash84](/maintainers/Ash84)

---

Top Contributors

[![juliocf94](https://avatars.githubusercontent.com/u/16273686?v=4)](https://github.com/juliocf94 "juliocf94 (17 commits)")

### Embed Badge

![Health badge](/badges/jc-as-crud-php-pure/health.svg)

```
[![Health](https://phpackages.com/badges/jc-as-crud-php-pure/health.svg)](https://phpackages.com/packages/jc-as-crud-php-pure)
```

###  Alternatives

[roots/bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure

6.5k456.5k2](/packages/roots-bedrock)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[vinkla/wordplate

The WordPlate boilerplate

2.2k5.3k](/packages/vinkla-wordplate)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

318117.1k1](/packages/cognesy-instructor-php)[phlak/directory-lister

PHP directory lister

2.5k1.4k](/packages/phlak-directory-lister)[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

41759.2k3](/packages/lullabot-drainpipe)

PHPackages © 2026

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