Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


include Adminer from different location?


  • Anonymous


    I'd like to use Adminer Editor in my new project. I don't want to have it's code in my git repository, so I've added it as a composer package in composer.json. Now I have all the Adminer files in the vendor directory which is not accessible from web browser. So I've created a file in my document root, called administration.php which includes adminer editor's index.php.

    The problem is that adminer is including some other files from it's directory using relative path but since it's been originally included from administration.php which is in located in the document root, PHP is lookig for the files in another directory.

    The only solution that occurred to me is to change all the includes in every Adminer file to use dirname(__FILE__). "/path" instead of just "./path".

    Could this problem be solved without having to change the Adminer files, or should I send you a pull request? :)

    Thanks in advance,

  • Jakub Vrána
    Jakub Vrána

    I would suggest using compiled version. With source codes, you would need to do this:

    1. Change all include "../adminer/ to include dirname(__FILE__) . "/adminer/.
    2. Define a constant ADMINER_ROOT to dirname(__FILE__) in index.php.
    3. Change all include "./ to include ADMINER_ROOT . "/.
    4. Do something about static files - e.g. symlink them from document root or create routes for them.

    You can also chdir(PATH_TO_ADMINER) in the file from which you include Adminer. But you still need to do something about the static files.