pub/index.php, the following code is used to set change URLs for media and static assets to omit "/pub":
$params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [ DirectoryList::PUB => [DirectoryList::URL_PATH => ''], DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'], DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'], DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload'], ]; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
Unfortunately in CLI scripts (
bin/magento) there is nothing like this.
I found the class
Magento\Setup\Mvc\Bootstrap\InitParamListener with the following code:
$initParams = $application->getServiceManager()->get(self::BOOTSTRAP_PARAM); $directoryList = $this->createDirectoryList($initParams);
But I don't understand where this Zend Service Manager retrieves the data and how it might be possible to influence it.
My concrete problem is that an indexer has to generate full URLs and currently does it like
http://magento.local/pub/media/..., where I need it to be
How can I tell the CLI that my virtual host points to
pub and "pub" should not be part of URLs?
Ideally this should work without having to rely on additional CLI parameters or environment variables.