2017 © Pedro Peláez
 

composer-plugin studio

Develop your Composer libraries with style

image

franzliedke/studio

Develop your Composer libraries with style

  • Monday, December 4, 2017
  • by franzliedke
  • Repository
  • 38 Watchers
  • 639 Stars
  • 221 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 41 Forks
  • 11 Open issues
  • 17 Versions
  • 3 % Grown

The README.md

studio

Develop your Composer libraries with style., (*1)

This package makes it easy to develop Composer packages while using them., (*2)

Instead of installing the packages you're working on from the Packagist repository, use Studio to symlink them from the filesystem instead. Under the hood, it uses Composer's path repositories to do so. As a result, you won't have to develop in the vendor directory., (*3)

Studio also knows how to configure development tools that might be part of your workflow. This includes the following:, (*4)

  • Autoloading (src and tests)
  • PhpUnit
  • PhpSpec
  • TravisCI

This list will only get longer in the future., (*5)

Installation

Studio can be installed globally or per project, with Composer:, (*6)

Globally (recommended): composer global require franzl/studio (use as studio), (*7)

Make sure that the ~/.composer/vendor/bin directory is added to your PATH, so that the studio executable can be located by your system., (*8)

Per project: composer require --dev franzl/studio (use as vendor/bin/studio), (*9)

Usage

All commands should be run from the root of your project, where the composer.json file is located., (*10)

Workflow

Typically, you will want to require one of your own Composer packages in an application. With Studio, you can pull in your local copy of the package instead of the version hosted on Packagist. The kicker: You can keep developing your library while you dogfood it, but you won't need to change your composer.json file., (*11)

Loading local packages

To use one of your own libraries within your application, you need to tell Studio where it can locate the library. You can do so with the load command. When Composer resolves its dependencies, Studio will then pitch in and symlink your local directory to Composer's vendor directory., (*12)

So, to have Studio manage your awesome world domination library, all you have to do is run the following command:, (*13)

$ studio load path/to/world-domination

This command should create a studio.json file in the current working directory. It contains a list of directories for Studio to load., (*14)

Next, if you haven't already done so, make sure you actually require the package in your composer.json:, (*15)

"require": {
    "my/world-domination": "dev-master"
}

And finally, tell Studio to set up the symlinks:, (*16)

$ composer update my/world-domination

If all goes well, you should now see a brief message along the following as part of Composer's output:, (*17)

[Studio] Loading path installer, (*18)

This is what will happen under the hood:, (*19)

  1. Composer begins checking dependencies for updates.
  2. Studio jumps in and informs Composer to prefer packages from the directories listed in the studio.json file over downloading them from Packagist.
  3. Composer symlinks these packages into the vendor directory or any other appropriate place (e.g. for custom installers). Thus, to your application, these packages will behave just like "normal" Composer packages.
  4. Composer generates proper autoloading rules for the Studio packages.
  5. For non-Studio packages, Composer works as always.

Pro tip: If you keep all your libraries in one directory, you can let Studio find all of them by using a wildcard:, (*20)

$ studio load 'path/to/my/libraries/*'

Kickstarting package development

If you haven't started world domination yet, Studio also includes a handy generator for new Composer packages. Besides the usual ceremony, it contains several optional components, such as configuration for unit tests, continuous integration on Travis-CI and others., (*21)

First, we need to create the local directory for the development package:, (*22)

$ studio create domination
# or if you want to clone a git repo
$ studio create domination --git git@github.com:vendor/domination.git

After asking you a series of questions, this will create (or download) a package in the domination subdirectory inside the current working directory. There is a good chance that you need a little time to develop this package before publishing it on Packagist. Therefore, if you ran this command in a Composer application, Studio will offer you to load your new package immediately. This essentially comes down to running studio load domination., (*23)

Finally, don't forget to use composer require to actually add your package as a dependency., (*24)

Command Reference

create: Create a new package skeleton

$ studio create foo/bar

This command creates a skeleton for a new Composer package, already filled with some helpful files to get you started. In the above example, we're creating a new package in the folder foo/bar in your project root. All its dependencies will be available when using Composer., (*25)

During creation, you will be asked a series of questions to configure your skeleton. This will include things like configuration for testing tools, Travis CI, and autoloading., (*26)

create --git: Manage existing packages by cloning a Git repository

$ studio create bar --git git@github.com:me/myrepo.git

This will clone the given Git repository to the bar directory and install its dependencies., (*27)

create --submodule: Manage existing packages by loading a Git repository as submodule

$ studio create bar --submodule git@github.com:me/myrepo.git

This will load the given Git repository to the bar directory as a submodule and install its dependencies., (*28)

create --options: Provide specific options to Git when loading the repository

$ studio create bar --git git@github.com:me/myrepo.git --options="--single-branch --branch=mybranch"
$ studio create bar --submodule git@github.com:me/myrepo.git --options="-b mybranch"

This will load the given Git repository and checkout a specific branch. To have an overview of all the options available to you, check git clone --help and git submodule add --help., (*29)

load: Make all packages from the given local path available to Composer

$ studio load baz

This will make sure all packages in the baz directory (paths with wildcards are supported, too) will be autoloadable using Composer., (*30)

unload: Stop managing a local path

$ studio unload foo

This will remove the path foo from the studio.json configuration file. This means any packages in that path will not be available to Composer anymore (unless they are still hosted on Packagist)., (*31)

This does not remove the package contents from the file system. See scrap for completely removing a package., (*32)

You can reload the path using the load command., (*33)

scrap: Remove a package

Sometimes you want to throw away a package. You can do so with the scrap command, passing a path for a Studio-managed package:, (*34)

$ studio scrap foo

Don't worry - you'll be asked for confirmation first., (*35)

License

This code is published under the MIT License. This means you can do almost anything with it, as long as the copyright notice and the accompanying license file is left intact., (*36)

Contributing

Feel free to send pull requests or create issues if you come across problems or have great ideas. Any input is appreciated!, (*37)

franzl/studio for enterprise

Available as part of the Tidelift Subscription, (*38)

The maintainers of franzl/studio and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more., (*39)

The Versions

04/12 2017

dev-master

9999999-dev

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

02/12 2017

0.14.x-dev

0.14.9999999.9999999-dev

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

02/12 2017

0.14.0-beta1

0.14.0.0-beta1

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

01/12 2017

0.13.0

0.13.0.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

15/09 2017

0.12.0

0.12.0.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

25/11 2016

0.11.2

0.11.2.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

19/11 2016

0.11.1

0.11.1.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

06/04 2016

0.11.0

0.11.0.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

06/04 2016

dev-next

dev-next

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

05/03 2016

0.10.0

0.10.0.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

25/03 2015

0.9.x-dev

0.9.9999999.9999999-dev

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

25/03 2015

0.9.5

0.9.5.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

17/03 2015

0.9.4

0.9.4.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

24/02 2015

0.9.3

0.9.3.0

Develop your Composer libraries with style

  Sources   Download

MIT

The Requires

 

The Development Requires

composer development workflow

23/02 2015

0.9.2

0.9.2.0

Develop your Composer libraries with style

  Sources   Download

The Requires

 

The Development Requires

22/02 2015

0.9.1

0.9.1.0

Develop your Composer libraries with style

  Sources   Download

The Requires

 

The Development Requires

22/02 2015

0.9.0

0.9.0.0

Develop your Composer libraries with style

  Sources   Download

The Requires

 

The Development Requires