erikdubbelboer/phpRedisAdmin

Install phpRedisAdmin through composer.json

Closed this issue · 5 comments

Hello Erik and thank you for your work.

I'm here to explain how to install phpRedisAdmin through composer.json, as I feel more comfortable listing my dependencies there. It's simple but as I'm not familiar with Composer, it took me a little time to figure out and I thought I'd share my experience. Feel free to hint at it in your documentation if you will :)

Since Composer by default doesn't let you install your projects in custom places (typically we need to install phpRedisAdmin in a /public/admin/ folder rather than the typical /vendor), you need to specify a custom installer in your composer.json, and the "installer-paths" Composer feature will then work with phpRedisAdmin. I found one by @mnsami that does just that.

So here's the code you put in your composer.json file :

{
    "extra": {
        "installer-paths": {
            "public/admin/phpredisadmin": ["erik-dubbelboer/php-redis-admin"]
        }
    },
    "require": {
        "mnsami/composer-custom-directory-installer": "1.0.*",
        "erik-dubbelboer/php-redis-admin": "1.4.0"
    }
}

When it's done, install the files with composer install or composer update.

It's not finished yet, as you'll get something like this when running the app :
Fatal error: require(): Failed opening required 'var/www/public/admin/phpredisadmin/includes/../vendor/autoload.php' (include_path='.:/usr/local/share/pear') in *var/www/public/admin/phpredisadmin/includes/common.inc.php on line 2.

You just need to create a symlink in public/admin/phpredisadmin named autoload.php that will point to your composer autoloader, typically vendor/autoload.php. Under Linux, that would be something like :

mkdir /var/www/public/admin/phpredisadmin/vendor
ln -s /var/www/vendor/autoload.php /var/www/public/admin/phpredisadmin/vendor/autoload.php

Simple as that ! Good luck :)

Since phpRedisAdmin is more of a stand-alone admin project I think it's a bit weird to install it as composer dependency in your project (you also not doing this with other tools like phpMyAdmin or any other editors I assume).

So I'm just going to leave this issue open as documentation for when other people want to do something like this.

I find it weird that you find it weird :) In case of emergency, I need a Redis admin panel to manage my project, so my project depends on it, so I consider it a dependency. Would you rather install it from Github manually or with a unix script just because it's not called by other project scripts ? Or how do you usually do ?

I don't really have it running per project. I just have a general example.com/admin/phpredisadmin on my server which I can use to manage the Redis instances running on that server.

I guess it's different for me because I'm not using Redis in any PHP projects.

It should suffice to use composer/installers to enable users like us to install your app wherever we need in a clear way

Please evaluate it .. it should be even very simple for you to satisfy this request ;)

As far as I can understand you have only to require composer/installers as dependency .. the custom path will be written in the USER (me) composer.json

Never mind .. composer/installers will only allow supported types ;(

I'm going to try composer-custom-directory-installer