Posts tagged with composer

Some awesome composer tricks

Composer really needs no introduction. At this point the PHP community pulled in billions of packages. Here are some Composer options that are not so well known.

You can view the versions of all the packages in your project by running composer show -i. Let's try it out in our Blender Laravel template:

composer -i

Want to see all the dependencies of the installed packages in a tree? Then run composer show -t:

composer -t

If you need help using a specific package then you can open it's documentation in a browser using composer. Try running composer home spatie/laravel-fractal to see it in action.

Know some other nice Composer tricks? Let me know in the comments below.

Read more

Fake the PHP version when running Composer

Mr. Composer, Jordi Boggiano, has posted an overview of composer features that have become available in the past year. A very nice one is config.platform.

The `config.platform` option lets you emulate which platform packages you have available on your prod environment. That way even if you have a more recent PHP version or are missing an extension locally for example, composer will always resolve packages assuming that you have the packages you declared installed.
That'll come in handy when you have a local php 7 environment and an older version installed on the server.

Read more

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Handling private composer packages with Satis

Satis allows you to require private php packages in your projects. One of it's authors is Jordi Boggiano of composer/packagist fame. Over at the excellent Laravelista blog Mario Bašić explains how to install and use it.

I was working on three projects at the same time and I've found myself copying code from one project to another and then making small changes. And then I recognized a pattern. ...

I created a package and as soon as it was ready for GitHub I remembered: "I can't open source this...". The package contained few paid html templates, company logo's, slogans, specific company text etc. ...

This post will explain what Satis is, when to use it and how to set it up on your server.

Read more

Tilde and caret version constraints in Composer

There are also some syntactic sugar operators like `~` (tilde) and `^` (caret).
  • `~4.1.3` means `>=4.1.3,<4.2.0`,
  • `~4.1` means `>=4.1.0,<5.0.0` (most used),
  • `~0.4` means `>=0.4.0,<1.0.0`,
  • `~4` means `>=4.0.0,<5.0.0`.
The caret sign is slightly different:
  • `^4.1.3` (most used) means `>=4.1.3,<5.0.0`,
  • `^4.1` means `>=4.1.0,<5.0.0`, same as `~4.1` but:
  • `^0.4` means `>=0.4.0,<0.5.0`, this is different from `~0.4` and is more useful for defining backwards compatible version ranges.
  • `^4` means `>=4.0.0,<5.0.0` which is the same as `~4` and `4.*`.
 
http://blog.madewithlove.be/post/tilde-and-caret-constraints/

Read more

The benefits of creating packages

by Freek Van der Herten – 1 minute read

In the last few months various little parts of our custom built CMS were made available as composer installable packages. Though creating a package takes some time, there are many benefits: my colleagues and my future self can benefit from the same documentation that is written for the consumers of…

Read more

Inside Composer's speed boost

If you've been following the news, you'll have noticed that yesterday Composer got a bit of a speed boost. And by "bit of a speed boost", we're talking between 50% and 90% reduction in runtime depending on the complexity of the dependencies. But how did the fix work? And should you make the same sort of change to your projects? For those of you who want the TL/DR answer: the answer is no you shouldn't.
http://blog.ircmaxell.com/2014/12/what-about-garbage.html

Read more