PHPackages                             fredoware/fredobase - 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. fredoware/fredobase

ActiveProject[API Development](/categories/api)

fredoware/fredobase
===================

A lightweight plain-PHP framework for database-backed CRUD APIs.

v0.1.1(1mo ago)08PHPPHP &gt;=7.4

Since Jul 14Pushed 1mo agoCompare

[ Source](https://github.com/fredoware/fredobaseapi)[ Packagist](https://packagist.org/packages/fredoware/fredobase)[ RSS](/packages/fredoware-fredobase/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

FredoBase
=========

[](#fredobase)

FredoBase is a lightweight plain-PHP API micro framework by Fredoware for quickly creating database-backed CRUD APIs.

It is intentionally small, readable, and easy to copy for future Fredoware projects.

FredoBase gives you:

- one bootstrap file
- reusable request/response/database helpers
- model factory functions
- file-based API endpoints
- SQL migrations
- module generator

Structure
---------

[](#structure)

```
api/                 Public API endpoint files
app/Core/            Core request, response, database, repository classes
app/Modules/         Controllers, repositories, and validators by module
app/Support/         Shared helpers, model factories, mail helper
database/            Schema and migration SQL files
docs/                Tutorials
routes/api.php       Module route definitions
fredobase            FredoBase CLI
.env.example         Environment template

```

Install With Composer
---------------------

[](#install-with-composer)

After the package is published on Packagist, create an application with:

```
composer create-project fredoware/fredobase my-api
cd my-api
```

Composer installs the dependencies and runs `php fredobase install`. The installer creates `.env`, generates a unique `APP_KEY`, and never overwrites an existing environment file.

Before the package is on Packagist, it can be tested directly from GitHub:

```
composer create-project fredoware/fredobase my-api dev-main --repository='{"type":"vcs","url":"https://github.com/fredoware/fredobaseapi"}'
```

Manual Setup
------------

[](#manual-setup)

1. Install dependencies and prepare the project:

```
composer install
php fredobase install
```

2. Check your database settings in `.env`:

```
DB_HOST=localhost
DB_DATABASE=appbase.db
DB_USERNAME=root
DB_PASSWORD=
```

3. Run migrations:

```
php fredobase migrate
```

4. Test the health endpoint:

```
http://localhost/appbase-api/api/health.php

```

Expected response:

```
{
  "status": "success",
  "message": "FredoBase API is running."
}
```

CLI Commands
------------

[](#cli-commands)

Show help:

```
php fredobase help
```

Prepare a new checkout (safe to run more than once):

```
php fredobase install
```

Create a CRUD module:

```
php fredobase make:module product
```

Run migrations:

```
php fredobase migrate
```

After adding a field to a module model, generate and apply its migration:

```
php fredobase make:migration product
php fredobase migrate
```

The module generator creates:

```
app/Modules/Product/ProductController.php
app/Modules/Product/ProductModel.php
app/Modules/Product/ProductRepository.php
app/Modules/Product/ProductValidator.php
database/migrations/YYYY_MM_DD_HHMMSS_create_product_table.sql

```

It also registers REST routes inside `routes/api.php`.

Starter Endpoints
-----------------

[](#starter-endpoints)

- `api/health.php` - API and database health check
- `api/authLogin.php` - basic account login
- `api/authLogout.php` - revoke the current bearer token
- `api/index.php` - dispatch routed module requests

Starter Tables
--------------

[](#starter-tables)

- `account` - minimal user/account table
- `auth_token` - hashed, expiring bearer tokens
- `sample_item` - generic CRUD example table

Creating A New Module
---------------------

[](#creating-a-new-module)

Read the full tutorial:

[docs/creating-a-module.md](docs/creating-a-module.md)

Quick version:

```
php fredobase make:module product
php fredobase migrate
```

Then test:

```
GET    http://localhost/appbase-api/api/products
GET    http://localhost/appbase-api/api/products/1
POST   http://localhost/appbase-api/api/products
PUT    http://localhost/appbase-api/api/products/1
DELETE http://localhost/appbase-api/api/products/1

```

Write routes require a bearer token by default. Existing file-based endpoints remain supported for backward compatibility.

Authentication
--------------

[](#authentication)

Run migrations and create the first administrator:

```
php fredobase migrate
php fredobase make:admin admin@example.com change-this-password Admin User
```

Login with a JSON `POST` request to `api/authLogin.php`. A successful response contains a bearer token. Send it to protected endpoints with:

```
Authorization: Bearer YOUR_TOKEN

```

Protect an endpoint and access the authenticated account with:

```
$user = requireAuth();
```

Require one or more roles with:

```
$admin = requireRole('Admin');
$staff = requireRole(['Admin', 'Staff']);
```

Revoke the current token by sending an authenticated `POST` request to `api/authLogout.php`. Token lifetime defaults to 24 hours and can be changed with `AUTH_TOKEN_TTL` in `.env`.

GitHub Notes
------------

[](#github-notes)

Commit `.env.example`, but do not commit `.env`.

The `.gitignore` already excludes `.env`, logs, temporary files, and uploaded media.

fredobaseapi
============

[](#fredobaseapi)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

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

Total

2

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/36f666249b09d204df82b08c0f778a7cbce4ee6c242dfaff1ad7e5f53bcd8ff4?d=identicon)[fredowinz23](/maintainers/fredowinz23)

---

Top Contributors

[![fredowinz23](https://avatars.githubusercontent.com/u/12025644?v=4)](https://github.com/fredowinz23 "fredowinz23 (6 commits)")

---

Tags

phpapicrudmicro-framework

### Embed Badge

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

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.8k40.0k](/packages/matomo-matomo)[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

11.3k4.0k](/packages/leantime-leantime)

PHPackages © 2026

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