Before diving into how to extend Pachno, let's have a quick look at some of the core concepts. Understanding these and the way they slot together - like building blocks - will help you when you're writing your extension.
Pachno is a modern php MVC application. This means it uses tools from all over the php ecosystem as well as modern php language features. If you're used to working with object oriented php, frameworks such as Laravel or Symfony and composer, you'll feel right at home.
We're building Pachno as a community project - feel free to get involved and suggest new ways we can leverage these tools.
Pachno consists of three main parts or layers:
- Framework and database backend - this is the glue that binds everything together. When you're working with requests and responses, looking up or persisting things in the database, or creating new pages, you'll work with the interfaces defined by the framework and database backend.
- Core functionality and entities - core functionality that is meant to be shared across several modules, such as settings, common data objects, tools and helpers.
- Modules - on top of the building blocks from the two first layers you find modules. These make up what you "see" or interact with when working with Pachno, whether it's the web application or the API. (Internally in Pachno you will se an internal separation between "core" modules and "external" modules, but functionality-wise they both leverage the exact same integration points. The only real difference is that "core" modules are always present and are installed with Pachno itself, whereas external modules can be added, removed and distributed to other installations)
When creating an extension, you should only ever have to work in the third layer. Sometimes you may see a need to fix, extend or improve either the core functionality, framework or database backend. If so, feel free to create an issue and submit a patch!
Creating your module
To get you started with everything you need to create your module, open up a command line console / terminal and run the
bin/pachno create_module command, where is a lowercase identifier for your module (this name also defines the module namespace, so use lowercase alphanumeric characters or underscores only). For the purpose of this tutorial, we will call the module
hello_world, so run
bin/pachno create_module hello_world if you want to follow along.
(If you're not familiar with the command line client, get a quick intro here: )
The cli will create all the necessary files for your module and place them under
Installing / enabling the module
Modules can be placed in the
modules/ directory, but they will not be active until they are installed. To install your new module, go to the configuration center and enable it in the "Manage modules" section, or run
bin/pachno manage_modules install hello_world from the command line.
Voilá! Your new module is now installed, activated and running. It doesn't do anything, but that's for another time.