Download the PHP package alexskrypnyk/customizer without Composer

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

Customizer logo

Interactive customization for template projects

[![GitHub Issues](https://img.shields.io/github/issues/AlexSkrypnyk/customizer.svg)](https://github.com/AlexSkrypnyk/customizer/issues) [![GitHub Pull Requests](https://img.shields.io/github/issues-pr/AlexSkrypnyk/customizer.svg)](https://github.com/AlexSkrypnyk/customizer/pulls) [![Test PHP](https://github.com/AlexSkrypnyk/customizer/actions/workflows/test-php.yml/badge.svg)](https://github.com/AlexSkrypnyk/customizer/actions/workflows/test-php.yml) [![codecov](https://codecov.io/gh/AlexSkrypnyk/customizer/graph/badge.svg?token=7WEB1IXBYT)](https://codecov.io/gh/AlexSkrypnyk/customizer) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/AlexSkrypnyk/customizer) ![LICENSE](https://img.shields.io/github/license/AlexSkrypnyk/customizer) ![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot)

The Customizer allows template project authors to ask users questions during the composer create-project command and then update the newly created project based on the received answers.

TL;DR

Run the command below to create a new project from the template project example and see the Customizer in action:

Features

Installation

  1. Add to the template project as a Composer dependency:

These entries will be removed by the Customizer after your project's users run the composer create-project command.

  1. Create customize.php file with questions and processing logic relevant to your template project and place it in anywhere in your project.

See the Configuration section below for more information.

Usage example

When your users run the composer create-project command, the Customizer will ask them questions and process the answers to customize their instance of the template project.

Run the command below to create a new project from the template project example and see the Customizer in action:

In this example, the demonstration questions will ask you to provide a package name, description, and license type. The answers are then processed by updating the composer.json file and replacing the package name in other project files.

--no-install

Your users may run the composer create-project --no-install command if they want to adjust the project before installing dependencies, for example. Customizer will not run in this case as it is not being installed yet and it's dependencies entries will stay in the composer.json file.

The user will have to run composer customize manually to run the Customizer. It could be useful to let your users know about this command in the project's README file.

Configuration

You can configure how the Customizer, including defining questions and processing logic, by providing an arbitrary class (with any namespace) in a customize.php file.

The class has to implement public static methods :

questions()

Defines questions, their discovery and validation callbacks. Questions will be asked in the order they are defined. Questions can use answers from previous questions received so far.

The discovery callback is optional and runs before the question is asked. It can be used to discover the default answer based on the current state of the project. The discovered value is passed to the question callback. It can be an anonymous function or a method of the configuration class named discover<QuestionName>.

The validation callback should return the validated answer or throw an exception with a message to be shown to the user. This uses inbuilt SymfonyStyle's ask() method for asking questions.

customize.php has an example of the questions() method.

Note that while the Customizer examples use SymfonyStyle's ask() method, you can build your own question asking logic using any other TUI interaction methods. For example, you can use Laravel Prompts.

process()

Defines processing logic for all answers. This method will be called after all answers are received and the user confirms the intended changes. It has access to all answers and Customizer's class public properties and methods.

All file manipulations should be done within this method.

customize.php has an example of the process() method.

cleanup()

Defines the cleanup() method after all files were processed but before all dependencies are updated.

customize.php has an example of the cleanup() method.

messages()

Defines overrides for the Customizer's messages shown to the user.

customize.php has an example of the messages() method. messages provided by the Customizer.

Example configuration

Click to expand an example configuration customize.php file

Helpers

The Customizer provides a few helpers to make processing answers easier. These are available as properties and methods of the Customizer $c instance passed to the processing callbacks:

Question validation helpers are not provided in this class, but you can easily create them using custom regular expression or add them from the AlexSkrypnyk/str2name package.

Developing and testing your questions

Testing manually

  1. Install the Customizer into your template project as described in the Installation section.
  2. Create a new testing directory and change into it.
  3. Create a project in this directory:

  4. The Customizer screen should appear.

Repeat the process as many times as needed to test your questions and processing logic.

Add export COMPOSER_ALLOW_XDEBUG=1 before running the composer create-project command to enable debugging with XDebug.

Automated functional tests

The Customizer provides a [test harness]](tests/phpunit/Functional) to help you test your questions and processing with ease.

The template project authors can use the same test harness to test their own questions and processing logic:

  1. Setup PHPUnit in your template project to run tests.
  2. Inherit your classes from CustomizerTestCase.php (this file is included into distribution when you add Customizer to your template project).
  3. Create a directory in your project with the name tests/phpunit/Fixtures/<name_of_test_snake_case> and place your test fixtures there. If you use data providers, you can create a sub-directory with the name of the data set within the provider.
  4. Add tests as base/expected directory structures and assert for the expected results.

See examples within the template project example.

Comparing fixture directories

The base test class CustomizerTestCase.php provides the assertFixtureDirectoryEqualsSut() method to compare a directory under test with the expected results.

The method uses base and expected directories to compare the results: base is used as a state of the project you are testing before the customization ran, and expected is used as an expected result, which will be compared to the actual result after the customization.

Because the projects can have dependencies added during composer install and other files that are not related to the customization, the method allows you to specify the list of files to ignore during the comparison using .gitignore-like syntax with the addition to ignore content changes but still assess the file presence.

See the description in assertFixtureDirectoryEqualsSut() for more information.

Maintenance

composer install   # Install dependencies.
composer lint      # Check coding standards.
composer lint-fix  # Fix coding standards.
composer test      # Run tests.

This repository was created using the getscaffold.dev project scaffold template


All versions of customizer with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
composer-plugin-api Version ^2.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 alexskrypnyk/customizer contains the following files

Loading the files please wait ....