Download the PHP package brianhenryie/strauss without Composer

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

Strauss – PHP Namespace Renamer

A tool to prefix namespaces, classnames, and constants in PHP files to avoid autoloading collisions.

A fork of Mozart for Composer for PHP.

Have you ever activated a WordPress plugin that has a conflict with another because the plugins use two different versions of the same PHP library? Strauss is the solution to that problem - it ensures that your plugin's PHP dependencies are isolated and loaded from your plugin rather than loading from whichever plugin's autoloader registers & runs first.

⚠️ Sponsorship: It would be neat if you were to offer me a license to your plugin, or at least post about where this is used.

Table of Contents

Installation

As a .phar file (recommended)

There are a couple of small steps to make this possible.

Create a bin/.gitkeep file

This ensures that there is a bin/ directory in the root of your project. This is where the .phar file will go.

.gitignore the .phar file

Add the following to your .gitignore:

Edit composer.json `scripts

In your composer.json, add strauss to the scripts section:

This provides composer strauss, which does the following:

  1. The sh -c command tests if bin/strauss.phar exists, and if not, downloads it from releases.
  2. Then @php bin/strauss.phar is run to prefix the namespaces.
  3. Ensure that composer's autoload map is updated.

As a dev dependency via composer (not recommended)

If you prefer to include Strauss as a dev dependency, you can still do so. You mileage may vary when you include it this way.

Edit composer.json `scripts

Usage

If you add Strauss to your composer.json as indicated in Installation, it will run when you composer install or composer update. To run Strauss directly, simply use:

To update the files that call the prefixed classes, you can use --updateCallSites=true which uses your autoload key, or --updateCallSites=includes,templates to explicitly specify the files and directories.

or

To try it out without making changes, you can use the --dry-run flag:

strauss --dry-run ![](.github/strauss.mp4)

Verbosity can be controlled with --notice (default), --info, --debug and --silent.

Configuration

Strauss potentially requires zero configuration, but likely you'll want to customize a little, by adding in your composer.json an extra/strauss object. The following is the default config, where the namespace_prefix and classmap_prefix are determined from your composer.json's autoload or name key and packages is determined from the require key:

The following configuration is inferred:

The following configuration is default:

To disable optimized/classmap-authoritative Composer autoload generation:

The remainder is empty:

Autoloading

Strauss uses Composer's own tools to generate a set of autoload files in the target_directory and creates an autoload.php alongside it, so in many projects autoloading is just a matter of:

If you plan to continue using Composer's autoloader you probably want to turn on delete_vendor_packages or set target_directory to vendor.

You can use strauss include-autoloader to add a line to vendor/autoload.php which includes the autoloader for the new files.

If you don't plan to use Composer's autoloader, you may wish to enable include_root_autoload so that the Strauss autoloader includes the autoload for your project.

When delete_vendor_packages is enabled, vendor/composer/autoload_aliases.php is created to allow modified classes to be loaded with their old name during development. This file should not be included in your production code.

Motivation & Comparison to Mozart

I was happy to make PRs to Mozart to fix bugs, but they weren't being reviewed and merged. At the time of writing, somewhere approaching 50% of Mozart's code was written by me with an additional nine open PRs and the majority of issues' solutions provided by me. This fork is a means to merge all outstanding bugfixes I've written and make some more drastic changes I see as a better approach to the problem.

Benefits over Mozart:

Strauss will read the Mozart configuration from your composer.json to enable a seamless migration.

Alternatives

I don't have a strong opinion on these. I began using Mozart because it was easy, then I adapted it to what I felt was most natural. I've never used these.

Interesting

Breaking Changes

Please open issues to suggest possible breaking changes. I think we can probably move to 1.0.0 soon.

Backward Compatibility Promise

This project will not increase its minimum required PHP version ahead of WordPress.

https://core.trac.wordpress.org/ticket/62622

Changes before v1.0

Changes before v2.0

The correct approach to this problem is probably via PHP-Parser. At least all the tests will be useful.

Acknowledgements

Coen Jacobs and all the contributors to Mozart, particularly those who wrote nice issues.


All versions of strauss with dependencies

PHP Build Version
Package Version
Requires ext-json Version *
composer-runtime-api Version ^2.0
brianhenryie/bh-php-flysystem-readonly Version ^1.0
brianhenryie/simple-php-code-parser Version ^0.17
composer/class-map-generator Version ^1.7.3
composer/composer Version ^2.10
elazar/flystream Version ^0.6.0 || ^1.4.0
inmarelibero/gitignore-checker Version ^1.0
json-mapper/json-mapper Version ^2.0.0
league/flysystem Version ^2.5.0 || ^3.35.1
league/flysystem-memory Version ^2.0.6 || ^3.31.0
monolog/monolog Version ^2.11 || ^3.10
nikic/php-parser Version ^5.8.0
symfony/console Version ^4 || ^5 || ^6 || ^7
symfony/finder Version ^4 || ^5 || ^6 || ^7 || ^8
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 brianhenryie/strauss contains the following files

Loading the files please wait ...