Download the PHP package stellarwp/models without Composer

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

StellarWP Models

A library for a simple model structure.

Table of Contents

Installation

It's recommended that you install Schema as a project dependency via Composer:

We actually recommend that this library gets included in your project using Strauss.

Luckily, adding Strauss to your composer.json is only slightly more complicated than adding a typical dependency, so checkout our strauss docs.

Notes on examples

Since the recommendation is to use Strauss to prefix this library's namespaces, all examples will be using the Boomshakalaka namespace prefix.

Configuration

This library requires some configuration before its classes can be used. The configuration is done via the Config class.

Creating a model

Models are classes that hold data and provide some helper methods for interacting with that data.

A simple model

This is an example of a model that just holds properties.

A ReadOnly model

This is a model whose intent is to only read and store data. The Read operations should - in most cases - be deferred to a repository class, but the model should provide a simple interface for interacting with the repository. You can create ReadOnly model by implementing the Contracts\ModelReadOnly contract.

A CRUD model

This is a model that includes CRUD operations. Ideally, the actual CRUD operations should be deferred to and handled by a repository class, but the model should provide a simple interface for interacting with the repository. We get a CRUD model by implementing the Contracts\ModelCrud contract.

Attribute validation

Sometimes it would be helpful to validate attributes that are set in the model. To do that, you can create validate_*() methods that will execute any time an attribute is set.

Here's an example:

Data Transfer Objects

Data Transfer Objects (DTOs) are classes that help with the translation of database query results (or other sources of data) into models. DTOs are not required for using this library, but they are recommended. Using these objects helps you be more deliberate with your query usage and allows your models and repositories well with the ModelQueryBuilder.

Here's an example of a DTO for breakfasts:

Repositories

Repositories are classes that fetch from and interact with the database. Ideally, repositories would be used to query the database in different ways and return corresponding models. With this library, we provide Deletable, Insertable, and Updatable contracts that can be used to indicate what operations a repository provides.

You may be wondering why there isn't a Findable or Readable contract (or similar). That's because the fetching needs of a repository varies with the usecase. However, in the Repository abstract class, there is an abstract prepareQuery() method. This method should return a ModelQueryBuilder instance that can be used to fetch data from the database.

Interacting with the Repository

Querying

Inserting

Updating

Deleting

Classes of note

Model

This is an abstract class to extend for your models.

ModelFactory

This is an abstract class to extend for creating model factories.

ModelQueryBuilder

This class extends the stellarwp/db QueryBuilder class so that it returns model instances rather than arrays or stdClass instances. Using this requires models that implement the ModelFromQueryBuilderObject interface.

DataTransferObject

This is an abstract class to extend for your DTOs.

Repositories\Repository

This is an abstract class to extend for your repositories.

Contracts of note

Contracts\ModelCrud

Provides definitions of methods for CRUD operations in a model.

Contracts\ModelHasFactory

Provides definition for factory methods within a model.

Contracts\ModelReadOnly

Provides method signatures for read operations in a model.

Repositories\Contracts\Deletable

Provides method signatures for delete methods in a repository.

Repositories\Contracts\Insertable

Provides method signatures for insert methods in a repository.

Repositories\Contracts\Updatable

Provides method signatures for update methods in a repository.


All versions of models with dependencies

PHP Build Version
Package Version
Requires stellarwp/db Version ^1.0.3
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 stellarwp/models contains the following files

Loading the files please wait ....