parse.com-php-library icon indicating copy to clipboard operation
parse.com-php-library copied to clipboard

Composer support

Open eminetto opened this issue 11 years ago • 5 comments

Added namespaces and Composer support

eminetto avatar Oct 24 '13 22:10 eminetto

pls merge this commit, we really need it for frameworks like Symfony2

Donjohn avatar Jan 17 '14 08:01 Donjohn

Hey I'll take a look at it again... I was 90% done with a new version of the library that was composer ready when this came across. I haven't had time to finish my yet. So, let me check it out again this weekend and maybe it'll be a quick fix until I can get my new version up.

andrewscofield avatar Jan 17 '14 09:01 andrewscofield

hi, any update on this feature ? meanwhile i did my own by copying the classes but can't be easy updated without composer.

Thx in advance.

Donjohn avatar Jan 27 '14 08:01 Donjohn

There is something can i do to help? :)

eminetto avatar Jul 11 '14 14:07 eminetto

For those who want to have this repo via Composer, add this to your composer.json file:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "apotropaic/parse.com-php-library",
                "version": "2.0",
                "source": {
                    "url": "https://github.com/apotropaic/parse.com-php-library",
                    "type": "git",
                    "reference": "master"
                },
                "autoload": {
                    "classmap": ["/"]
                }
            }
        }
    ],
    "require": {
        "apotropaic/parse.com-php-library": "2.0"
    },
    "scripts" : {
        "post-install-cmd": "<specify class to fix issues>",
        "post-update-cmd": "<the same class once again>"
    }
}

"scripts" section is required in order to fix a few issues:

  1. In parse.php need to replace all "include" to "include_once" so it won't mess up with composer autoloader.
  2. parseConfig.php should be added.
  3. Typo in parseQuery.php, need to replace "installation" with "installations".
class ComposerFix
{
    public static function postInstall()
    {
        $source = __DIR__ . '/parseConfig';
        $distDir = __DIR__  . '/../../../vendor/apotropaic/parse.com-php-library';
        $dist = $distDir . '/parseConfig.php';

        copy($source, $dist);

        $fileName = $distDir . '/parseQuery.php';

        file_put_contents($fileName, str_replace("'installation'", "'installations'", file_get_contents($fileName)));

        $fileName = $distDir . '/parse.php';

        file_put_contents($fileName, str_replace('include ', 'include_once ', file_get_contents($fileName)));
    }
}

antonCPU avatar Aug 01 '14 13:08 antonCPU