Download the PHP package hkt/psr7-asset without Composer
On this page you can find all versions of the php package hkt/psr7-asset. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package psr7-asset
Psr7Asset
Asset management for PHP. This package is a fork of Aura.Asset_Bundle.
Foreword
Requirements
Installation
You can use any psr-17 libraries.
Tests
or you may use;
PSR Compliance
This attempts to comply with PSR-1, PSR-2, PSR-4, PSR-7, PSR-15 and PSR-17. If you notice compliance oversights, please send a patch via pull request.
Structure of Package
Assume you have a Vendor.Package
. Your assets can be any where. Consider it is in the
public
folder. The folder names css
, images
, js
can be according to your preffered name.
Assuming you have the same structure, now in your template you can point
to /asset/vendor/package/css/some.css
, /asset/vendor/package/js/hello.js
, /asset/vendor/package/images/another.jpg
.
Routing
The library can be used with any framework. So it makes use of preg_match
under the hood. The default regular expression is /\/asset\/([a-zA-Z0-9-_]+)\/([a-zA-Z0-9-_]+)\/(.*)/
.
You can modify the regular expression when intantiating the Router
object which is passed as 3rd argument to AssetAction
.
Zend Expressive
If you are using `zend expressive you can configure,
AuraRouter
FastRoute
NB : Make sure you have set the service
Hkt\Psr7Asset\AssetAction
to the Di container.
From your view you can use as
This will return /asset/vendor/package/css/bootstrap.min.css
.
Mapping
With the help of mapping the vendor/package
or directly the path you can alter the result it returns.
Eg :
Overriding css, js, images
Like puli it is possible that you can override the style sheet, images, js etc for the downloaded package. You just need to map it. No magic under the hood.
Eg :
Caching
The asset files are served by PHP. There is an experimental repo https://github.com/harikt/psr7-asset-cache that can do caching. So files can be served by the web server itself.
Configuration via Aura.Di
Pass Hkt\Psr7Asset\Container\AssetConfig
to your
Container Builder.
Don't forget to set the service Interop\Http\Factory\ResponseFactoryInterface
as below.
All versions of psr7-asset with dependencies
psr/http-factory Version ^1.0
psr/http-message Version ^1.0
psr/http-server-middleware Version ^1.0