Custom Repositories for GitHub Forked Composer packages

So today we had to make a custom repository so that our composer installs could look for custom changes to a particular package that was causing a problem with one of our client’s production applications.

The only current change in this particular package was a solitary “if” statement added to a single line of code. This statement checks to make sure that the object operated on is indeed an object: in certain situations in the production app it throws a fatal exception claiming a “non-object.”

First we had to ask two (rhetorical) questions:

(1) Where do PHP Composer packages come from?

and

(2) How do you get composer to install a non-composer package?

The first step was to fork the package on GitHub:

The original package is Piotr Śliwa’s excellent:

https://github.com/psliwa/PHPPdf

And the fork lives here:

https://github.com/yourcomputergenius/PHPPdf

We looked at simply adding the forked package to Packagist, but although we intend on maintaining this as a “real long-term fork”, that is only if this change or an equivalent fix are not added to the primary package in the near to medium term. Since that seems like an edge case, we were happy to go the VCS route. Satis and Toran Proxy just looked like overkill for this simple implementation.

Once the forking was complete, we cloned the forked package into GitHub for Mac (nice!).

We branched into “missing-object-protection” (the name of the branch will be important later).

We edited the file “lib/PHPPdf/Core/ComplexAttribute/ComplexAttribute.php”, committed the change, and pushed.

Then on to editing composer.json.

We tried to run “composer require” and “composer update” on a development version of the application, after “composer remove” took care of the original psliwa/PHPPdf package. However, we ran into the issue that our newly created PHPPdf branch no longer satisfied the requirements for the PDF Bundle dependencies that was also used by the production app!

Back to GitHub we went, and we forked:

https://github.com/psliwa/PdfBundle

to:

https://github.com/yourcomputergenius/PdfBundle/

Then we cloned that into the desktop and made a solitary commit to the new fork’s master branch: a single commit updating the requirements in that project’s composer.json.

Then we updated our repositories in our development machine’s composer.json, just after the “require-dev” entry, so it contained entries for both newly forked packages:


    "repositories": {
        "yourcomputergenius/php-pdf": {
            "type": "vcs",
            "url":  "https://github.com/yourcomputergenius/PHPPdf/"
        },
        "yourcomputergenius/php-bundle": {
            "type": "vcs",
            "url": "https://github.com/yourcomputergenius/PdfBundle/"
        }
    },


We were able to leave the names the same in the “require” section of the composer.json file — one of the beautiful (and maddening) things about composer is the presence of these sorts of conventions. Composer is smart enough to figure out which packages are being replaced by custom repos.

However, we did update the “require” section of composer.json to look for the “dev-missing-object-protection” branch, as below:


        "psliwa/php-pdf": "dev-missing-object-protection"


The long and short of the day is that the application runs “composer update” and successfully grabs those two packages from the forked repos. Hooray!

This post is part of the thread: Software Development – an ongoing story on this site. View the thread timeline for more context on this post.

Why 3rd Party Providers (i.e. Google) for OpenID/OAuth is a bad idea:

Why OAuth 3rd Party Providers are a bad ideaScreenshot 2015-01-07 09.44.01

Both @LucidChart and @SaneBox are using the old methods… and probably many more startups as well!

@LucidChart Why no version numbers insert?

Screenshot 2015-01-05 07.59.01

Screenshot 2015-01-05 07.59.31

Screenshot 2015-01-05 07.59.50

 

Updates to PHP 5.4 Cause Errors in Pagelines

 

The error is: Warning: Creating default object from empty value in /wp-content/themes/platform/includes/class.layout.php on line 167

 

And the solution (turn off displayed errors):

 

add to wp-config.php
ini_set( ‘display_errors’, 0 );

http://wordpress.org/support/topic/warning-error-creating-default-object-from-empty-value

Somewhere in here there is a way to display 500 Errors in Remote Browsers with II 7.x

http://stackoverflow.com/questions/2640526/detailed-500-error-message-asp-iis-7-5
http://stackoverflow.com/questions/2640526/detailed-500-error-message-asp-iis-7-5/2640607#2640607
http://www.ksingla.net/2009/02/iis75_updates_to_custom_errors_and_compression/

Fascinating stuff about what Job Offers tell us about corporate architecture

http://lzone.de/What-Job-Offers-Tell-About-Architectures-4

Getting Excited about Sophos new UTM Offerings

 

Sophos UTM Offerings

 

http://www.sophos.com/en-us/products/unified-threat-management/how-to-buy.aspx

Contact us if you are interested!

Super Cool: The Rise of IO Domains

http://www.russellbeattie.com/blog/artisanal-websites-the-rise-of-io-domains-for-well-crafted-web-services

New Favorite Inexpensive Desktop

We have been recommending these to everyone:

Just don’t buy up the whole stock of them as we have more clients to order them for!

Likely Next Laptop: Acer V5-122P-0857

Acer laptop Backlit keyboard…

Touch screen…

Have to upgrade to SSD, and replace Windows 8.