Search code examples
phpsymfonyroutesvendor

Symfony2 - routing php app from vendor


I would like to route php script from Vendor. I used Composer to instal database managment (https://github.com/vrana/adminer/). Source of that app is: vendor/vrana/adminer/adminer/index.php

I would like to create router to use this app, for example when I call url myweb.com/adminer, it should load that source: vendor/vrana/adminer/adminer/index.php

Is it possible to do it via routing.yml ? Something like this:

adminer:
    resource: "Vendor/vrana/adminer/adminer/index.php"
    prefix:   /adminer

Or how it possible to do it?


Solution

  • It is not possible via symfonys routing.yml, since this needs the app kernel to be started, which is in app.php. But you can just set up adminer as another server.

    If you use apache for example write in /etc/apache2/sites-enabled/local

    <VirtualHost *:80>
        ServerName local.adminer
        DocumentRoot /YourPathToAdminer
        DirectoryIndex adminer.php
        <Directory /YourPathToAdminer>
            AllowOverride all
            Allow from all
        </Directory>
        LogLevel debug
    </VirtualHost>
    

    And in your /etc/hosts add somewhere

    127.0.0.1       local.adminer
    

    Just call http://local.adminer in your browser and you are done.