Download the PHP package williarin/cook without Composer

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

Cook

Baking recipes for any PHP package.

Github Workflow

Introduction

Cook is a Composer plugin that executes recipes embedded in packages, in a similar fashion to Symfony Flex. It can be used alongside with Flex, or in any other PHP project, as long as Composer is installed.

Features

Installation

Make sure to allow the plugin to run. If it's not added automatically, add this in your composer.json file:

Documentation

Creating a recipe

Take a look at williarin/cook-example for a working example of a Cook recipe.

To make your package Cook-compatible, you just have to create a valid cook.yaml or cook.json at the root directory.

The recipe schema must follow this structure:

Top level parameter Type Comments
files array Individual files to be created or merged.
directories array List of directories to be entirely copied from the package to the project.
post_install_output string A text to display after installation or update of a package.

Files

Files are a described as key-value pairs.

If a string is given, it must be a path to the source file.

Parameter Type Comments
type string Type of file.

Choices:
  • text
  • php_array
  • json
  • yaml
  • docker_compose
Default: text
Optional
destination string Path of the destination file in the project that will be created or merged.

Required
source string Path of the source file in the package which content will be used to create or merge in the destination file.

Required if content isn't defined
content string Text to merge in the destination file.

Required if source isn't defined
entries array<string, mixed> Key-value pairs used to fill a PHP or JSON array.

Required if type is of type php_array or json
filters {keys: array\, values: array\} Filters for entries when type is php_array.

Choices:
  • keys
    • class_constant Convert the given string to a class constant. As an example, 'Williarin\Cook' becomes Williarin\Cook::class
  • values
    • class_constant See above
    • single_line_array If the value is an array, it will be exported on a single line
Optional
valid_sections array\ Used if type is yaml or json in order to restrict which top-level parameters need to be merged.

Example: [parameters, services]

Optional
blank_line_after array\ Used if type is yaml in order to add a blank line under the merged section.

Example: [services]

Optional
uninstall_empty_sections boolean Used if type is yaml in order to remove an empty recipe section when uninstalling the recipe.

Default: false
Optional

Directories

Directories are a described as key-value pairs.

Post install output

Maybe you want to display some text to the user after installation.
You can use colors using Symfony Console syntax.

Mergers

Text

The text merger can be used to extend any text-based file such as:

As it's the default merger, you can simply use the destination: source format in the recipe.

Example 1: merge or create a .env file with a given source file

Given yourrepo/recipe/.env with this content:

With this recipe:

The created .env file will look like this:

The ###> yourname/yourrepo ### opening comment and ###< yourname/yourrepo ### closing comment are used by Cook to identify the recipe in the file. If you're familiar with Symfony Flex, the syntax is the same.

Example 2: merge or create a .env file with a string input

Alternatively, you can use content instead of source, to avoid creating a file in your repository.

PHP array

The PHP array merger adds new entries to existing arrays or creates a file if it doesn't exist.

Example 1: without filters

This recipe will create or merge the file config/bundles.php in the project.

The output will look like this:

Example 2: with filters

Let's add some filters to our entries.

The output will look like this:

JSON

The JSON merger adds new entries to an existing JSON file or creates a file if needed.

Note: Only top-level keys are merged.

Example:

This recipe will add a script in the composer.json file of the project.

The output will look like this:

YAML

The YAML merger adds new parameters to top-level parameters in an existing file or creates a file if needed.

Although a YAML file represents arrays like JSON or PHP arrays, the specificity of this merger is to allow YAML comments. Therefore, instead of using entries which restricts content as key-value pairs, you need to describe the content to merge as a string, or a YAML file.

Example 1: default config

Given this existing file in config/services.yaml:

With this recipe:

The output will look like this:

Example 2: with blank lines

To make things a bit prettier, let's add a blank line below our services merge:

The output will look like this:

Note: the YAML merger is only able to prepend existing content, not append.

Uninstalling YAML recipe

When uninstalling a recipe, the YAML merger will not remove the entire section if it's empty, unless you set the uninstall_empty_sections parameter to true.

In this example, if the other_routes section is empty, it will be removed when uninstalling the recipe.

Docker Compose

The Docker Compose merger is similar to the YAML merger with only specific sections that would be merged.

Only services, volumes, configs, secrets and networks top-level sections will be merged.

Placeholders

You can use several placeholders in your destination and source paths:

You can override any of these placeholders by defining them in your composer.json file.

Any other variable defined in extra is available with %YOUR_VARIABLE% in your recipe.

CLI

You may want to execute your recipes after installation. Cook provides you this command to execute all available recipes:

It won't overwrite your configuration if it already exists. To overwrite everything, run:

Additionally, you can uninstall a recipe with this command:

Use either <package> for individual package uninstallation or --all for all packages.

License

MIT

Copyright (c) 2023, William Arin


All versions of cook with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
composer-plugin-api Version ^2.3
colinodell/indentation Version ^1.0
symfony/config Version ^5.4 || ^6.0 || ^7.0
symfony/dependency-injection Version ^5.4 || ^6.0 || ^7.0
symfony/filesystem Version ^5.4 || ^6.0 || ^7.0
symfony/finder Version ^5.4 || ^6.0 || ^7.0
symfony/options-resolver Version ^5.4 || ^6.0 || ^7.0
symfony/validator Version ^5.4 || ^6.0 || ^7.0
symfony/var-exporter Version ^5.4 || ^6.0 || ^7.0
symfony/yaml Version ^5.4 || ^6.0 || ^7.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 williarin/cook contains the following files

Loading the files please wait ....