libra/libra-assets-installer

Makes accessible vendor assets (js, css, images) by creating/updating symlink to public/vendor/vendor-name folder

Installs: 3 569

Dependents: 9

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 2

Open Issues: 0

Type:assets-installer

2.3.0 2018-01-20 07:09 UTC

This package is not auto-updated.

Last update: 2024-11-09 12:16:02 UTC


README

##Description This package will help you to develop your vendor package with comfortable structure of public assets in public directory at root folder of your package. It will create symlink to this folder in public/vendor/vendor-name/package-name. So file public/css/screen.css will be accessible in view by:

$this->basePath() . '/vendor/vendor-name/package-name/css/screen.css';

At version 2.0.0 was changed logic of installing to use custom installer and rely on package type.

  • If your package is some assets like jquery, jquery-ui or twitter-bootsrap etc., you should set up type of package to asset. Then add to require list this package like

    {
        "name":         "vendor-name/asset-package-name",
        "type":         "asset"
        "require": {
            "libra/libra-assets-installer":     "~2.0"
        }
    }
    

    After installing assets will be in public/vendor/vendor-name/asset-package-name.

  • If you create standard ZF2 module that contains public assets into public directory
    then use "type": "asset-aware":

    {
        "name":         "vendor-name/package-with-assets-name",
        "type":         "asset-aware"
        "require": {
            "libra/libra-assets-installer":     "~2.0"
        }
    }
    

    Then contents of package-with-assets-name/public folder will be symlinked or on failure copied to public/vendor/vendor-name/package-with-assets-name

So URL will be the same in both cases.

##Options There available options (in format "type default"):

  • public-dir (only in root package)
    • if you wish put asset into another folder - put its name above
  • package-asset-dir (not available for type = asset)
    • if your asset dir has another name - put it above
  • add-target-dir: bool false/true (may be suitable for symfony bundles)
    • if enabled add target dir path to public asset path
    • Since v3.0 always true, DEPRECATED.

Some example:

    "extra": {
        "package-asset-dir": "assets"
    }

In root package:

    {
        "config": {
            "public-dir": "httdocs",
        }
    }

Note! For Zend Framework 2 modules it don't need to set up any configurations as usually.

##Instructions for ver. 1.* Despite of its working even in version 2.* you should'n rely on it feature in late version. This feature can be removed in any time in higher version but will be present in ver. 1.. I encourage to use ver, 2..

Note : For working this module you should set it first in required list in composer.json. Also supports Windows Vista/Windows Server 2008 or greater by php documentation. But really tested only under Linux. It uses symlink function hence behaviour at Windows unknown for me.

###Using: In root composer.json add this packages to required list as first item. Add this lines in root composer:

    "scripts": {
        "post-package-install":  "LibraAssetsInstaller\\Installer::postPackageInstall",
        "pre-package-uninstall": "LibraAssetsInstaller\\Installer::prePackageUninstall",
        "post-package-update":   "LibraAssetsInstaller\\Installer::postPackageUpdate"
    }

At first It was created for Libra CMS.