Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Last active May 30, 2018 14:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ocramius/26a9fc80278017ed8f72 to your computer and use it in GitHub Desktop.
Save Ocramius/26a9fc80278017ed8f72 to your computer and use it in GitHub Desktop.
Add a PSR-4 namespace to a composer.json file
#!/usr/bin/env php
<?php
file_put_contents(
'composer.json',
json_encode(array_merge_recursive(
['autoload' => ['psr-4' => [$argv[1] => $argv[2]]]],
json_decode(file_get_contents('composer.json'), true)
))
);
@frankdejonge
Copy link

<?php
file_put_contents(
    'composer.json',
    json_encode(array_merge_recursive(
        ['autoload' => ['psr-4' => [$argv[1] => $argv[2]]]],
        json_decode(file_get_contents('composer.json'), true)
    ), JSON_PRETTY_PRINT)
);

@Ocramius
Copy link
Author

Life is too short to look up the PHP docs, looking for non-class constants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment