Download the PHP package glhd/special without Composer

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

Build Status Coverage Status Latest Stable Release MIT Licensed Follow @inxilpro on Twitter

Special✨

Sometimes, certain database records are just special✨, and you need to reference them inside your code.

You might have a few special vendors that have special handling in a few special places, and maybe their own special artisan commands run from time-to-time.

special✨ lets you use backed enums to reference Eloquent models. Rather than backing your enum with a string or integer, think of it as backing your enum with a database record.

If the record is missing, you can let special✨ automatically create it for you. This is especially great in testing, where you may have a few special records that need to exist for a few special tests, but you don't want to track which tests need to run special seeders at setup.

Installation

Usage

To start, create a new enum and use the EloquentBacking trait provided by this package.

You can optionally add a CreateWith attribute to any of your enum cases, and special✨ will use those values to automatically create the model record for you if it's missing.

Now, you can use those enums to access the backing models. By default, strings are assumed to be a slug column, and integers are assumed to be the id column, but this can be configured at the project level or the individual enum level.

Special enums decorate the underlying model, so you can often just call the enum as though it were the model itself. But sometimes you want the actual copy of the model instance, which you can do with:

Using the primary key cache

Often, the only reason you need a special enum is to use its primary key in another query or to set up a relationship. Special✨ keeps a cache of the 50 most recently-used primary keys so that in many cases, you don't have to do a single database lookup. You can configure the number of keys cached and the cache TTL by publishing the package config.

As long as SpecialOrganizations::Laravel has been used in the last hour, the 'organization_id' value can be set without making a single query to the database.

Due to the nature of these kinds of enums, this is usually pretty safe, since they're used with the types of records that aren't likely to change in your application ever. That said, you can always clear the cache at any time with php artisan cache:clear-special-keys.

Using with Laravel relations

Often times you want to use a special enum to look up related models. We provide a few convenient ways to do this:

Or, you can use a special enum to constrain an existing query. The exact same query can be generated with:

The constrain() method (and forSpecial macro) both use the primary key cache under the hood. This means that most relational queries using special enums will not trigger any additional database queries.

Automatic Model Observation

Special✨ automatically registers model observers for any model that you retrieve. This means that if you update or delete a special model during a request, subsequent calls to the enum will automatically reflect those changes.

This works regardless of whether the updated model was retrieved using the package.


All versions of special with dependencies

PHP Build Version
Package Version
Requires php Version >= 8.1
illuminate/support Version ^8|^9|^10|^11|12.x-dev|dev-master
illuminate/database Version ^8|^9|^10|^11|12.x-dev|dev-master
ext-json Version *
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 glhd/special contains the following files

Loading the files please wait ....