PHPackages                             growtech/acf-core-php - 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. growtech/acf-core-php

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

growtech/acf-core-php
=====================

Advanced Custom Fields for Core PHP — dynamic custom field management for non-WordPress PHP applications.

00PHP

Since Jun 19Pushed todayCompare

[ Source](https://github.com/Singh-developer/acf-core-php)[ Packagist](https://packagist.org/packages/growtech/acf-core-php)[ RSS](/packages/growtech-acf-core-php/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Advanced Custom Fields for Core PHP
===================================

[](#advanced-custom-fields-for-core-php)

A lightweight, dependency-free custom field engine for vanilla PHP applications — the flexibility of WordPress ACF, without WordPress.

Requirements
------------

[](#requirements)

- PHP 7.4+ (tested on 8.3)
- MySQL or MariaDB
- `pdo_mysql` extension

Installation
------------

[](#installation)

**Option A — no Composer:**

```
require_once '/path/to/acf-core-php/autoload.php';
```

**Option B — with Composer**, add to your `composer.json`:

```
"repositories": [{ "type": "path", "url": "path/to/acf-core-php" }],
"require": { "yourvendor/acf-core-php": "*" }
```

Then load the schema once:

```
mysql -u youruser -p your_database  'localhost', 'dbname' => 'my_app',
    'username' => 'db_user', 'password' => 'db_password',
], [
    'base_path' => __DIR__ . '/public/uploads/acf', // where files are written
    'base_url'  => '/uploads/acf',                  // public URL prefix
]);

// 2. One-time setup (run from a migration/seed script)
$groupId = ACF::createFieldGroup(['title' => 'Product Details', 'entity_type' => 'product']);
ACF::addField($groupId, ['label' => 'Price', 'name' => 'price', 'type' => 'number', 'required' => true]);

// 3. Render a form
echo ACF::renderForm('product', $productId, ['wrap_form' => true, 'form_attrs' => ['action' => '/save']]);

// 4. Save submitted data
try {
    ACF::save('product', $productId, $_POST, $_FILES);
} catch (ValidationException $e) {
    $errors = $e->getErrors(); // ['field_name' => ['message', ...]]
}

// 5. Read values back
$values = ACF::getValues('product', $productId);          // raw values
$display = ACF::getValues('product', $productId, true);   // template-ready (formatted dates,  tags, etc.)
```

See `examples/full_integration_example.php` for a complete worked example (bootstrap, setup, form, save handler, display template).

Supported Field Types
---------------------

[](#supported-field-types)

Type`type` stringNotesText`text``validation_rules`: `min_length`, `max_length`, `pattern`Textarea`textarea``options.rows`, `validation_rules`: `min_length`, `max_length`Number`number``validation_rules`: `min`, `max`, `step`Email`email`Validated with `FILTER_VALIDATE_EMAIL`URL`url`Validated with `FILTER_VALIDATE_URL`Select`select``options.choices` (assoc array), `options.multiple` (bool)Checkbox group`checkbox``options.choices`; always stores/returns an arrayRadio`radio``options.choices`File upload`file``options.accept` (e.g. `.pdf,.docx`), `options.subdir`, `options.max_size` (bytes)Image upload`image`Same options as `file`; validates actual image content, not just extensionDate`date`Stored as `Y-m-d`; `validation_rules.min_date`/`max_date`; `options.display_format` (PHP date format)Rich text`richtext`Plain `` — attach your own WYSIWYG JS (TinyMCE/Quill/etc). HTML is sanitized against an allow-list on save.Adding a Custom Field Type
--------------------------

[](#adding-a-custom-field-type)

```
use ACF\FieldTypes\AbstractFieldType;

class ColorField extends AbstractFieldType
{
    public function render(array $field, $value = null): string { /* ... */ }
    public function validate(array $field, $value): array { /* ... */ }
    public function sanitize(array $field, $value) { /* ... */ }
    public function display(array $field, $value) { /* ... */ }
}

ACF::registerFieldType('color', ColorField::class);
```

See `examples/CustomColorField.php` for a full working example.

Core API Reference
------------------

[](#core-api-reference)

**Setup**

- `ACF::configure(array $dbConfig, ?array $uploadConfig = null)`
- `ACF::registerFieldType(string $type, string $className)`

**Field groups &amp; fields**

- `ACF::createFieldGroup(array $data): int`
- `ACF::addField(int $groupId, array $data): int`
- `ACF::getFields(string $entityType, ?string $groupSlug = null): array`
- `ACF::updateFieldGroup() / deleteFieldGroup() / updateField() / deleteField()`

**Forms**

- `ACF::renderForm(string $entityType, ?int $entityId, array $options = []): string`
    - `options`: `group_slug`, `errors`, `wrap_form`, `form_attrs`

**Validation &amp; saving**

- `ACF::validate(string $entityType, array $postData, array $files = []): array` — error array, empty if valid
- `ACF::save(string $entityType, int $entityId, array $postData, array $files = []): bool` — throws `ValidationException` on invalid data

**Reading values**

- `ACF::getValue(string $entityType, int $entityId, string $fieldName, bool $forDisplay = false)`
- `ACF::getValues(string $entityType, int $entityId, bool $forDisplay = false): array`
- `ACF::deleteEntityValues(string $entityType, int $entityId): bool`

Notes on File Uploads
---------------------

[](#notes-on-file-uploads)

- Stored values are relative paths (e.g. `products/cover-64f2a1.png`), built from `UploadConfig`'s `base_path`/`base_url`.
- Re-saving a form without selecting a new file preserves the existing stored file — it won't be wiped.
- `display()` output for `file`/`image` fields returns ready-to-print ``/`` tags.

Styling
-------

[](#styling)

`assets/acf.css` has minimal default styles using plain class names (`.acf-field`, `.acf-errors`, etc.) — safe to override or ignore entirely if you're bringing your own design system.

Project Structure
-----------------

[](#project-structure)

```
acf-core-php/
├── autoload.php              # zero-dependency PSR-4-style autoloader
├── composer.json             # optional, if you prefer Composer's autoloader
├── database/schema.sql       # 3-table schema: field_groups, fields, field_values
├── src/
│   ├── ACF.php                # main facade — the class you'll actually call
│   ├── Core/                  # Database, FieldGroup, Field, FieldValue, UploadConfig
│   ├── FieldTypes/            # one class per field type + the factory/registry
│   ├── Validation/Validator.php
│   ├── Render/FormRenderer.php
│   └── Exceptions/
├── examples/
│   ├── full_integration_example.php
│   └── CustomColorField.php   # custom field type example
└── assets/acf.css

```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/117cb9927a051800ec27dce291e262972c1633ff2653ebe3783e46281e54e0b1?d=identicon)[Grow tech](/maintainers/Grow%20tech)

---

Top Contributors

[![harjotxcode](https://avatars.githubusercontent.com/u/130464643?v=4)](https://github.com/harjotxcode "harjotxcode (2 commits)")

### Embed Badge

![Health badge](/badges/growtech-acf-core-php/health.svg)

```
[![Health](https://phpackages.com/badges/growtech-acf-core-php/health.svg)](https://phpackages.com/packages/growtech-acf-core-php)
```

###  Alternatives

[classpreloader/classpreloader

Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case

37642.7M32](/packages/classpreloader-classpreloader)[ronanguilloux/php-gpio

GPIO-related utils &amp; toolkit PHP library

2678.0k](/packages/ronanguilloux-php-gpio)[elephox/mimey

PHP package for converting file extensions to MIME types and vice versa.

14240.0k5](/packages/elephox-mimey)[kicken/gearman-php

A PHP implementation of the Gearman protocol.

1662.8k3](/packages/kicken-gearman-php)[heyday/silverstripe-wkhtml

Provides Wkhtml functionality in SilverStripe

1539.2k1](/packages/heyday-silverstripe-wkhtml)[log1x/acf-move-wp-editor

A simple ACF Field that moves the WordPress content editor of a post or page to the location of this field.

361.1k](/packages/log1x-acf-move-wp-editor)

PHPackages © 2026

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