Download the PHP package nystudio107/craft-closure without Composer

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

Scrutinizer Code Quality Code Coverage Build Status Code Intelligence Status

No Maintenance Intended

DEPRECATED

This Craft CMS module is no longer supported or maintained, but it is fully functional, and you may continue to use it as you see fit. The license also allows you to fork it and make changes as needed for legacy support reasons.

Instead, use Twig 3.1.5's native functionality for arrow functions everywhere.

Closure for Craft CMS

Allows you to use arrow function closures in Twig

While Closure is a bit of a monkey patch, it's a pretty clean/simple one that relies on functionality that is already built into Twig

Requirements

Closure requires Craft CMS 4.x or 5.x

Installation

To install Closure, follow these steps:

  1. Open your terminal and go to your Craft project:

    cd /path/to/project
  2. Then tell Composer to require the package:

    composer require nystudio107/craft-closure

About Closure

Twig supports arrow function closures, but only in the filter, map, and reduce filters.

Twig unfortunately has no plans to allow for more widespread usage of arrow function closures.

Craft Closure allows you to use arrow function closures anywhere, which is especially useful with Laravel Collection methods, many of which take a closure as a parameter.

Using Closure

Once you've added the nystudio107/craft-closure package to your project, no further setup is needed. This is because it operates as an auto-bootstrapping Yii2 Module.

You can then pass an arrow function closure as a parameter to anything that accepts them, such as many Laravel Collection methods:

Or you can assign an arrow function closure to a Twig variable for re-use:

Using arrow function closures especially useful now that Craft element queries can all return a Collection via the .collect() method.

More on Arrow Functions in Twig

More here: Twig Arrow Functions

Closure Roadmap

Some things to do, and ideas for potential features:

Brought to you by nystudio107


All versions of craft-closure with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
craftcms/cms Version ^4.3.0 || ^5.0.0
twig/twig Version ^3.0.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 nystudio107/craft-closure contains the following files

Loading the files please wait ....