Download the PHP package yard/data without Composer

On this page you can find all versions of the php package yard/data. 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 data

WP Data Objects

Code Style PHPStan Tests Code Coverage Badge Lines of Code Badge

Powerful data objects for WordPress.

Requirements

Installation

You can install this package with Composer:

You can publish the config file with:

Usage

PostData

Creating PostData

PostData can be created from the global \WP_Post object:

From an array:

Or from an Eloquent Model using Corcel:

Custom PostData

Creating a VacancyData object by extending PostData:

Enables you to create VacancyData object in the same way as PostData:

Configuring the returning Instance

Every time you call Yard\Data\PostData::from($post) you receive an instance of Yard\Data\PostData.

If you choose to create a new data class for your custom post type, you can have this class be returned for all instances of that post type.

To do this, you need to add the Fully Qualified Class Name (FQCN) of your custom data class to the supports array when registering your custom post type:

`

Another option is to create a mapping in the config/yard-data.php file. The mapping in the project config takes precedence over the register_post_type supports args.

Now every time you call Yard\Data\PostData::from($post) on a custom post type the mapped instance will be returned.

Meta Fields

Using the Meta Attribute

Adding a meta field with a meta_key of vacancy_email to your VacancyData looks like this:

This approach is functionally equivalent to using:

You can also specify any available Data Object, and the meta value will be cast to that Data Object:

The MetaPrefix Class Attribute

If all of your meta fields are prefixed with the same prefix you can use the MetaPrefix attribute:

It doesn’t matter if your meta keys are in snake_case and your attributes are in camelCase. For instance, let’s say your meta key is vacancy_members_only:

Taxonomy Terms

Adding terms to your Data Object

For every taxonomy that has been registered with your custom post type you can add a Collection of TermData like this:

This approach is functionally equivalent to using:

or:

The TaxonomyPrefix Class Attribute

If all of your taxonomies are prefixed with the same prefix you can use the TaxonomyPrefix attribute:

Reading Terms from your Data Object

Because Terms are a Collection you can use any of the available collection methods to read the terms from your data object. Here are some common examples:

Extending TermData

You can add extra meta fields to taxonomies by extending the default TermData object

In your PostData object you have to specify the data class used for a specific taxonomy:

Reading comments for your Data Objects

If the post type of the data object supports comments, you can retrieve them as a collection of CommentData

Extending CommentData

You can add extra meta fields to comments by extending the default CommentData object

UserData

Create UserData from current user:

About us

banner


All versions of data with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
jgrossi/corcel Version ^7.0
spatie/laravel-data Version ^4.5
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 yard/data contains the following files

Loading the files please wait ...