Simple solution for managing packages in Nette framework.
What problems can it solve?
- Registering extensions to
Nette\Compiler
- Creating default config structure in
config.neon
- Publishing directory with assets into
%wwwDir%
- Resolving paths to packages by simple syntax
Install package manager
composer require venne/packages:@dev // as a dependency
# composer create-project venne/packages:@dev // aside from the project
add hooks to root composer.json
file
{
"scripts": {
"post-install-cmd": [
"vendor/bin/package-manager sync --composer"
],
"post-update-cmd": [
"vendor/bin/package-manager sync --composer"
]
}
}
Use it by composer commands
composer require kdyby/doctrine
If you have already created composer.json
file, you're done ;)
Metadata
Metadata allow you to define advanced features:
relativePublicPath
: directory with asset files.configuration
: array will be copied toconfig.neon
file.installers
: array of classes implementsVenne\Packages\IInstaller
.
There are three ways how to define metadata:
{
"extra": {
"venne": {
"relativePublicPath": "/Resources/public",
"configuration": {
"extensions": {
"translation": "Kdyby\\Translation\\DI\\TranslationExtension"
}
},
"installers": [
"Namespace\MyInstaller"
]
}
}
}
Implement interface Venne\Packages\IPackage
<?php
namespace MyProject;
class Package extends \Venne\Packages\Package {}
Fork and edit https://github.com/Venne/packages-metadata
Package manager can provide some services which you can use it in your application. Make sure that you have installed package manager as dependency:
composer require venne/packages:@dev
Now you are using it as regular package. Not only independent package manager.
Service for resolving paths to packages by @
syntax. Use .
as separator between project and package name. For example: @kdyby.doctrine
.
$pathResolver = $container->getByType('Venne\Packages\PathResolver');
echo $pathResolver->expandPath('@my.package/foo/bar'); // /path_to_my_package/foo/bar
echo $pathResolver->expandResource('@my.package/foo/bar'); // {$resourcesDir}/my/package/foo/bar
New macros and new possibilities in classic macros:
{path @my.package/file} // browser_path_to_my.package/file
{extends @my.package/@layout.latte} // extends from other package
{includeblock @my.package/@layout.latte} // include blocks from template
vendor/bin/package-manager list # List packages
vendor/bin/package-manager sync # Synchronize all packages with filesystem
vendor/bin/package-manager install <name> # Install package
vendor/bin/package-manager uninstall <name> # Uninstall package
composer require foo/bar:2.0.x [--prefer-dist] # Download package
vendor/bin/package-manager update # Update local database of packages
vendor/bin/package-manager install foo.bar # Install package