Download the PHP package namshi/utility-bundle without Composer
On this page you can find all versions of the php package namshi/utility-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download namshi/utility-bundle
More information about namshi/utility-bundle
Files in namshi/utility-bundle
Package utility-bundle
Short Description A bunch of utilities we find pretty useful and use in our web systems.
License MIT
Informations about the package utility-bundle
NAMSHI | UtilityBundle
This bundle provides some basic, silly utilities that we use across our Symfony2 applications.
Installation
The bundle can be easily installed via
composer ("namshi/utility-bundle": "dev-master"
).
More informations available on Packagist.
Then enable it in the AppKernel.php
:
Doctrine CommaSeparatedList type
If you want to persist an array into the
DB as a list of comma-separated strings (ie.
to be able to execute FIND_IN_SET)
you can simply use the Namshi\UtilityBundle\ORM\Type\CommaSeparatedList
type.
Remember to register it inside Symfony2's config.yml
:
and then use it on your entities:
File serving with authentication
One of the utilities that you can take advantage of is file serving, mixing it with authentication.
Suppose you have a file, protected.txt
,
in /path/to/symfony2/data/protected.txt
and you want only some users to be able
to access it.
You just have to enable a route that tells the bundle which file to serve:
and define the file path in the parameters.yml
:
At that point you will be able to access the
content of the file (it uses file_get_contents()
, so
don't try using this utility as a download manager).
How to restrict access to the file then? Simply use
the built-in ACL system that you have in Symfony2:
configure your security.yml
for the path ^/protected.txt
and you're done.
Currency conversion
Totally unrelated to Symfony2, but included here for (our) conveniency, there is a currency converter that accepts conversion rates and can be used to easily convert an amount from a currency to another one.