Introduction
In this blog, I am going to explain How to create a new UVdesk extension framework package from scratch. First, you need to understand the following:
-
- Package: An abstract entity similar to a programming language class or a software project
- Application: The concrete form of a Package similar to an object of class or software product.
STEP 1:
- Browse to the apps directory present in your project’s root directory
- Create a new directory structure uvdesk/package-name inside the apps directory
- Browse to the package-name directory
STEP 2:
- Inside package-name directory create src and templates directory
- Create a new file extension.json which holds package metadata like name, author, autoload, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
// extension.json { "name": "uvdesk/package-name", "description": "Description", "type": "uvdesk-module", "authors": [ { "name": "name", "email": "examle@xxx.com" } ], "autoload": { "UVDesk\\CommunityPackages\\VendorName\\PackageName\\": "src/" }, "package": { "UVDesk\\CommunityPackages\\VendorName\\PackageName\\PackageNamePackage": ["all"] } } |
STEP 3:
- Inside the templates, directory put the appropriate configuration files like template files for parsing your application configuration
STEP 4:
- Inside the src directory create the following directories
- The resources directory contains the following directories:
- CSS for CSS stylesheets
- js for javascript files
- images for image files
- config directory contains services.yaml for configuring your package’s services with the extension framework
- you can also put a directory for routes inside the config directory that may hold your package’s routing configuration files.
- DependencyInjection for holding package data template i.e. structure and type of data your package is going to handle.
- The routing directory contains metadata class files that tell where to look for your package’s routes
- Apps directory for holding your package application metadata like name, app icon,
STEP 5:
- Extend/Implements the following classes/Interfaces:
- Application (Webkul\UVDesk\ExtensionFrameworkBundle\Definition\Application) representing the application you are creating. For more info consult uvdesk extension-framework
- ApplicationMetadata (Webkul\UVDesk\ExtensionFrameworkBundle\Definition\Application\ApplicationMetadata) which will holds metadata information about your package application.
-
ProtectedRoutingResourceInterface (Webkul\UVDesk\ExtensionFrameworkBundle\Definition\Routing\ProtectedRoutingResourceInterface) tells the extension framework where to look for your package’s private routes
-
ExposedRoutingResourceInterface (Webkul\UVDesk\ExtensionFrameworkBundle\Definition\Routing\ExposedRoutingResourceInterface) tells the extension framework where to look for your package’s public routes
STEP 6:
- Now you need to tell the extension framework whether your package is configurable or not.
- Create a new class inside the src directory with the following name PackageNamePackage
Simple Package:
- Make it extend/implement the following:
-
Package (Webkul\UVDesk\ExtensionFrameworkBundle\Definition\Package\Package)PackageInterface (Webkul\UVDesk\ExtensionFrameworkBundle\Definition\Package\PackageInterface)
- For more info consult uvdesk extension-framework
-
Configurable Package:
- Make it extend/implement the following
-
ConfigurablePackage (Webkul\UVDesk\ExtensionFrameworkBundle\Definition\Package\ConfigurablePackage)ConfigurablePackageInterface (Webkul\UVDesk\ExtensionFrameworkBundle\Definition\Package\ConfigurablePackageInterface)
- You also need to create a PackageConfiguration class that will live inside the DependenyInjection namespace of your package
- The PackageConfiguration class needs to implments symfony’s ConfigurationInterface (Symfony\Component\Config\Definition\ConfigurationInterface).
- This class will contain a single method called getConfigTreeBuilder() which will return an instance of Symfony’s TreeBuilder (Symfony\Component\Config\Definition\Builder\TreeBuilder) representing your package data template.
- For more info consult uvdesk extension-framework
-