Download the PHP package wp4laravel/corcel-acf without Composer

On this page you can find all versions of the php package wp4laravel/corcel-acf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package corcel-acf

Corcel ACF Plugin

Travis Packagist Packagist

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

This Corcel plugin allows you to fetch WordPress custom fields created by the ACF plugin using the same syntax of Eloquent, from the Laravel Framework. 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.

Installation

To install the ACF plugin for Corcel is easy:

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

Usage

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

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:

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

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

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!).

Fields

Field Status Developer Returns
Text ok @jgrossi string
Textarea ok @jgrossi string
Number ok @jgrossi number
E-mail ok @jgrossi string
URL ok @jgrossi string
Password ok @jgrossi string
WYSIWYG (Editor) ok @jgrossi string
oEmbed ok @jgrossi string
Image ok @jgrossi Corcel\Acf\Field\Image
File ok @jgrossi Corcel\Acf\Field\File
Gallery ok @jgrossi Corcel\Acf\Field\Gallery
Select ok @jgrossi string or array
Checkbox ok @jgrossi string or array
Radio ok @jgrossi string
True/False ok @jgrossi boolean
Post Object ok @jgrossi Corcel\Post
Page Link ok @jgrossi string
Relationship ok @jgrossi Corcel\Post or Collection of Post
Taxonomy ok @jgrossi Corcel\Term or Collection of Term
User ok @jgrossi Corcel\User
Google Map missing
Date Picker ok @jgrossi Carbon\Carbon
Date Time Picker ok @jgrossi Carbon\Carbon
Time Picker ok @jgrossi Carbon\Carbon
Color Picker ok @jgrossi string
Repeater ok @jgrossi Collection of fields
Flexible Content ok @marcoboom Collection

Contributing

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

Running Tests

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

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

MIT License © Junior Grossi


All versions of corcel-acf with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2|^8.0.2
jgrossi/corcel Version ^4.0|^5.0|^6.0|^7.0|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wp4laravel/corcel-acf contains the following files

Loading the files please wait ....