Download the PHP package dashifen/repository without Composer

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

dashifen/repository

Repository (noun): a place, building, or receptacle where things are or may be stored.

This package defines an object, AbstractRepository, that provides read-only access to its protected properties using __get(). If there are protected properties that need to remain hidden from external scopes, you can specify a list that won't be returned in that way.

Installation

composer install dashifen/repository

Usage

There are two ways to go here:

  1. Extend the AbstractRepository object.
  2. Extend the Repository object.

If you extend the abstract object, you'll be forced to implement three methods:

  1. getHiddenPropertyNames - returns an array of properties that should remain inaccessable via the arrow operator,
  2. getCustomPropertyDefaults - sets more complex default values than can be set during property declaration,
  3. getRequiredProperties - returns a list of properties that must have values after object instantiation.

The Repository object has already implemented these methods; they each return empty arrays.

Construction

The constructor for a Repository takes an associative array of data such that the indices are the names of properties and the array values will be set as the values for the listed properties. If you write a setter, it'll be called with the values for validation purposes.

The constructor's array argument's indices can either be in the expected camel case for the object's properties or in kabob case as in HTML attributes. Thus, an index of start-date would be "linked" to the startDate property.

Getters

Typically, because a Repository exposes protected properties, getting them with the arrow operator is the way to go. But, if you want to transform the internal representation of a property for external scopes, you can define a getter for a property that performs a transformation and returns its results. For example, converting a date from YYYY-MM-DD format into MM/DD/YYYY for display on-screen.

Getters must be in the form of "get" . ucfirst($propertyName). So, the startDate property would have a getter of getStartDate(). Getters can, themselves, be protected if you want to hide them from external scopes and rely on the __get() implementation and the arrow operator for access.

Setters

Repositories do not implement __set(), so you have to write them yourself. By default, the AbstractRepository object will use setters within it's __construct() method. So, if you extend that object, you must create a setter for each of your properties that are expected to be used by that constructor, i.e. those properties referenced by the constructor's array parameter.

Like getters, they must be in the format of "set" . ucfirst($propertyName). Thus, the setter for startDate must be setStartDate(). If you implement setters, they will be called from the Repository's constructor when it iterates over it's array argument. Because they're called from the constructor, they can be protected or private to create an object with read-only properties after construction.

Example

Array-able

There is a toArray method for Repositories to extract property names and values for non-hidden properties of the object.

JsonSerializable

Repositories implement the JsonSerializable interface. Therefore, you can encode them and non-hidden protected properties will be included in the JSON string that action produces.

Iterator

Repositories implement the Iterator interface. This allows you to use them in a foreach loop. Using the Foo object defined in our example above ...

... would produce ...

... skipping the baz property because it's hidden.

dashifen/container

This object is a new name for the old dashifen/container object. To avoid any confusion relating to the shared name with the PSR-11 Container Interface, I've simply changed the name from container to repository. All future work on this object will occur here. If you're still using the old object, I'd recommend switching your code and using this one instead.


All versions of repository with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
dashifen/case-changing-trait Version ^1
dashifen/exception Version ^1
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 dashifen/repository contains the following files

Loading the files please wait ....