magento-hackathon / magento-composer-installer

Composer installer for Magento modules
210 stars 154 forks source link

symlink mappings #153

Open davidverholen opened 9 years ago

davidverholen commented 9 years ago

Hey Daniel,

recently I found out that my Installer is not able to map the Danslo Api Import correctly. https://github.com/bragento/bragento-composer-installer/issues/17

His Mapping in the modman file is: code app/code/local/Danslo/ApiImport/

The expected behavior for this file defined in the symlink Strategy is: dir app/etc/ --> link app/etc/dir to dir

So this would be app/code/local/Danslo/ApiImport/code to code

What apparently is wrong.

But, in the Hackathon Installer it's working. So that leaves 2 options, fix this and make the affected programmers change their mappings, or just change the expected behavior (which might be the much easier way).

I'm not quite sure about this since the expected behavior defined in the symlink strategy seems pretty much orientated at the basic Linux file operations, which seems to be the right way to do this.

Flyingmana commented 9 years ago

how does the original modman behave in this case?

davidverholen commented 9 years ago

it does map it right to app/code/local/Danslo/ApiImport to code So it seems as if the expected behavior is wrong

flancer64 commented 9 years ago

Hello, I have tried to deploy Magento using "symlink" strategy and have found that a lot of code from method \MagentoHackathon\Composer\Magento\Installer\MagentoInstallerAbstract::getDeployStrategy is not used. The last method was called is \MagentoHackathon\Composer\Magento\Installer\CoreInstaller::getDeployStrategy:

    public function getDeployStrategy(PackageInterface $package, $strategy = null)
    {
        $deployStrategy = new Core($this->getSourceDir($package), $this->getTargetDir());
        $deployStrategy->setIgnoredMappings($this->getModuleSpecificDeployIgnores($package));
        return $deployStrategy;
    }

I have changed this code to:

    public function getDeployStrategy(PackageInterface $package, $strategy = null)
    {
        $deployStrategy = new Core($this->getSourceDir($package), $this->getTargetDir());
        $deployStrategy->setIgnoredMappings($this->getModuleSpecificDeployIgnores($package));
        $result = parent::getDeployStrategy($package, $deployStrategy);
        return $result;
    }

and now I can deploy Magento using "symlink" strategy.

davidverholen commented 9 years ago

That was the desired behavior.

Currently, the Core is also deployed with the normal mappings mechanism. The mappings for the core are on the first directory level of the magento root dir.

If you deploy the magento core with symlink strategy and then install a module with symlink strategy, you will end up with nested symlinks which can break the installation.

flancer64 commented 9 years ago

Thanks, David. Currently "the normal mappings mechanism" for the Core ("magento/core" module) is a "copy" strategy. "Symlink" strategy will not be used for "magento/core" module anymore. Do I understand correctly?

Thanks again.

davidverholen commented 9 years ago

yes, because when you symlink the core, there is for example one link from magentoroot/app pointing to vendor/magento/core/app.

If you now install a module, the symlink should be pointing from magentoroot/app/code/community/Company/Module to for example vendor/company/module/code

since magentoroot/app now points to vendor/magento/core/app, the symlink will be created at vendor/magento/core/app/code/community/Company/Module and it will be linked to ../../../../../vendor/company/module/code.

This will be a broken symlink because the directory structure in vendor differs from the directory structure in magento root.

I know it's even more difficult if your not that deep into this project ;) But, in short, it will create broken symlinks for magento modules in most cases

flancer64 commented 9 years ago

OK, thanks David :)

Magento Composer is the great product (y)

davidverholen commented 9 years ago

a way to fix this is to deploy everything on file level and don't symlink directories. I'm not sure if @Flyingmana has planned this now for the 3.0 release. I'm currently also trying to achieve that in another Project