PHPackages                             wp4laravel/corcel-acf - 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. wp4laravel/corcel-acf

ActiveLibrary

wp4laravel/corcel-acf
=====================

Advanced Custom Field (ACF) plugin for Corcel

v0.1.0(1y ago)02.2k1MITPHPPHP &gt;=7.2|^8.0.2

Since Aug 22Pushed 1y ago3 watchersCompare

[ Source](https://github.com/WP4Laravel/corcel-acf)[ Packagist](https://packagist.org/packages/wp4laravel/corcel-acf)[ Docs](http://github.com/corcel/acf)[ RSS](/packages/wp4laravel-corcel-acf/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

Corcel ACF Plugin
=================

[](#corcel-acf-plugin)

[![Travis](https://camo.githubusercontent.com/84c3b6fa56f65661d0fdd362a88a25fa6c16ed517a698b16e05a587d44026772/68747470733a2f2f7472617669732d63692e6f72672f636f7263656c2f6163662e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/corcel/acf?branch=master)[![Packagist](https://camo.githubusercontent.com/84a32c9356834fb0cbd63a37b8c5e77fd26e53f60856213a4ef1e5c832773b05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f7263656c2f6163662e737667)](https://github.com/corcel/acf/releases)[![Packagist](https://camo.githubusercontent.com/69241871acb418343f82a82f1eec37b7329c8890be4531ca8ec17fdb687463b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f7263656c2f6163662e737667)](https://packagist.org/packages/corcel/acf)

> Fetch all Advanced Custom Fields (ACF) fields inside Corcel easily.

This Corcel plugin allows you to fetch WordPress custom fields created by the [ACF](http://advancedcustomfields.com) plugin using the same syntax of Eloquent, from the [Laravel Framework](http://laravel.com). You can use Eloquent models and Collections to improve your development, using the WordPress backend with any PHP application.

For more information about how Corcel works please visit [the repository](http://github.com/jgrossi/corcel).

- [Installation](#installation)
- [Usage](#usage)
    - [The Idea](#the-idea)
    - [What is Missing](#what-is-missing)
    - [Fields](#fields)
- [Contributing](#contributing)
    - [Running Tests](#running-tests)
- [Licence](#licence)

Installation
============

[](#installation)

To install the ACF plugin for Corcel is easy:

```
composer require WP4Laravel/corcel-acf

```

Corcel is required for this plugin, but don't worry, if it's missing it will be installed as well.

Usage
=====

[](#usage)

This is a development version so the usage can change further. The desired behavior of this plugin is to allow this:

```
$post = Post::find(1);
echo $post->acf->url; // returns the url custom field created using ACF
```

Performance
-----------

[](#performance)

When using something like `$post->acf->url` the plugin has to make some extra SQL queries to get the field type according ACF approach. So we created another way to get that without making those extra queries. You have only the inform the plugin what is the post type, as a function:

```
// Extra queries way
echo $post->acf->author_username; // it's a User field

// Without extra queries
echo $post->acf->user('author_username');
```

> PS: The method names should be written in `camelCase()` format. So, for example, for the field type `date_picker` you should write `$post->acf->datePicker('fieldName')`. The plugin does the conversion from `camelCase` to `snake_case` for you.

The Idea
--------

[](#the-idea)

Using the default `$post->meta->field_name` in Corcel returns the value of the `meta_value` column in the `wp_postmeta` table. It can be a string, an integer or even a serialized array. The problem is, when you're using ACF this value can be more than that. If you have an integer, for example, it can be a `post id`, an `user id` or even an array of `posts ids`.

ACF has to make 2 (two) SQL queries to find out the field type, so according the type it has different behavior with the `meta_value`. For example, if the value is `45` and the `post type` is `post_object`, the value `45` is a post with ID `45`. So, in this case, Corcel should return a `Corcel\Post` instance instead of just an integer.

First ACF fetches the `meta_value` in `wp_postmeta` table, where the `meta_key` is something like `_field_name` and the post ID is the ID of the post you want the custom field. The returned value is the `field key` and it looks like this `field_57f421a2b81bd`. With this key it fetches the corresponding post in `wp_posts`, where `post_name = 'field_57f421a2b81bd'`. With the results it gets the `post_content` value, a serialized array, deserialize it and gets the content on the `type` key. This is the field type. According it the ACF (and also this plugin) does the right thing.

This plugin works with a basic logic inside `Corcel\Acf\Field\BasicField` abstract class, that has a lot of useful functions to return the `field key`, the `value`, etc. The `Corcel\Acf\FieldFactory` is responsible to return the correct field instance according the field type, so, if the field type is `post_object` it return an instance of `Corcel\Acf\Field\PostObject`, and it will returns in the `get()` method an instance of `Corcel\Post`.

What is Missing
---------------

[](#what-is-missing)

First we should create the fields classes and the test cases. After we have to setup how Corcel is going to work with the `corcel/acf` plugin, returning the custom field value in the format `$post->meta->field` or maybe `$post->acf->field` having different behavior (done!).

- Create more unit tests for `Repeater` field;
- Implement the `Flexible Content` field with unit tests (done!);
- Improve performance. Currently the plugin makes one SQL query for each field. This goal is to improve that using `whereIn()` clauses.

Some fields are still missing (check table below and contribute).

Fields
------

[](#fields)

FieldStatusDeveloperReturnsTextok[@jgrossi](http://github.com/jgrossi)`string`Textareaok[@jgrossi](http://github.com/jgrossi)`string`Numberok[@jgrossi](http://github.com/jgrossi)`number`E-mailok[@jgrossi](http://github.com/jgrossi)`string`URLok[@jgrossi](http://github.com/jgrossi)`string`Passwordok[@jgrossi](http://github.com/jgrossi)`string`WYSIWYG (Editor)ok[@jgrossi](http://github.com/jgrossi)`string`oEmbedok[@jgrossi](http://github.com/jgrossi)`string`Imageok[@jgrossi](http://github.com/jgrossi)`Corcel\Acf\Field\Image`Fileok[@jgrossi](http://github.com/jgrossi)`Corcel\Acf\Field\File`Galleryok[@jgrossi](http://github.com/jgrossi)`Corcel\Acf\Field\Gallery`Selectok[@jgrossi](http://github.com/jgrossi)`string` or `array`Checkboxok[@jgrossi](http://github.com/jgrossi)`string` or `array`Radiook[@jgrossi](http://github.com/jgrossi)`string`True/Falseok[@jgrossi](http://github.com/jgrossi)`boolean`Post Objectok[@jgrossi](http://github.com/jgrossi)`Corcel\Post`Page Linkok[@jgrossi](http://github.com/jgrossi)`string`Relationshipok[@jgrossi](http://github.com/jgrossi)`Corcel\Post` or `Collection` of `Post`Taxonomyok[@jgrossi](http://github.com/jgrossi)`Corcel\Term` or `Collection` of `Term`Userok[@jgrossi](http://github.com/jgrossi)`Corcel\User`Google MapmissingDate Pickerok[@jgrossi](http://github.com/jgrossi)`Carbon\Carbon`Date Time Pickerok[@jgrossi](http://github.com/jgrossi)`Carbon\Carbon`Time Pickerok[@jgrossi](http://github.com/jgrossi)`Carbon\Carbon`Color Pickerok[@jgrossi](http://github.com/jgrossi)`string`Repeaterok[@jgrossi](http://github.com/jgrossi)`Collection` of fieldsFlexible Contentok[@marcoboom](http://github.com/marcoboom)`Collection`Contributing
============

[](#contributing)

All contributions are welcome. Before submitting your Pull Request take a look on the following guidelines:

- Make your changes in a new git branch, based on the `develop` branch: `git checkout -b my-fix-branch develop`;
- Create your patch/feature, including appropriate test cases. Tests are necessary to make sure what you did is working and did not break nothing in the plugin;
- Run the unit tests and ensure that all tests are passing. Please, when submitting your PR paste the results of the `phpunit` command to facilitate the approval job;
- In GitHub, send a pull request to `corcel/acf:develop`, **always**. Do not send PR to our `master` branch! We encourage you to use `git flow` () workflow to make your life easier. It' not necessary, but it'll also be good for your development career;
- Make sure your code is following the `PSR-2` conventions ().

Running Tests
-------------

[](#running-tests)

To run the phpunit tests, execute `phpunit` (if you have a global PHPUnit executable) or try the following command:

```
./vendor/bin/phpunit

```

You should import the `database.sql` file to a database inside your local environment to make the tests working. Just unzip the `tests/config/database.sql.zip` file and set the database, user and password fields in `tests/config/bootstrap.php`.

> If you want to access the WordPress Admin Panel just use username as `admin` and password `123456`.

Licence
=======

[](#licence)

[MIT License](http://jgrossi.mit-license.org/) © Junior Grossi

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity34

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

Unknown

Total

1

Last Release

625d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d23630df3f8e70e643fd7215276c71d3a48e60c573cea555fa28ddba0da7087?d=identicon)[stephandebruin](/maintainers/stephandebruin)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wp4laravel-corcel-acf/health.svg)

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

###  Alternatives

[corcel/acf

Advanced Custom Field (ACF) plugin for Corcel

132343.9k7](/packages/corcel-acf)[corcel/woocommerce

WooCommerce plugin for Corcel

11132.3k](/packages/corcel-woocommerce)[tbruckmaier/corcel-acf

Advanced Custom Field (ACF) plugin for Corcel

3020.9k](/packages/tbruckmaier-corcel-acf)[wp4laravel/wp4laravel

Laravel with Wordpress as CMS

1214.0k](/packages/wp4laravel-wp4laravel)

PHPackages © 2026

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