Grav Package Management

This is a short description and comparison for the Package Management Methods available and used in Grav CMS. Mainly, these are three:

  • General Packages like Grav itself and its Components, done via Composer
  • Native Grav Packages (Plugins and Themes), done by bin/gpm
  • direct use of online Repositorys, like GitHub

The first 2 Methods have very much in common (both offer searching, installing, updating and removing packages, including dependency resolving), but the main distinction is that Composer is a general Purpose Package Manager which can be used to install any PHP Package that is available at Packagist , whereas gpm is solely made for installation/maintenance of Grav extensions (Plugins and Themes) available in the Grav Directory.
So, in short, anyone who wants to develop Grav Themes and/or Plugins, will most likely first create an appropriate GitHub Project, then evaluate if there are dependencies from native Grav Packages. In case of 'yes', these have to be included in the project's blueprints.yaml File.
Next step is to check if any 3rd Party Packages are to be used. If so, and if these are available in Packagist, they can simply be installed by using 'composer install package-name' in your Project Directory. As a result, all necessary source code Files as well as Documentation, will be downloaded, and a File 'autoload.php' will be created in the 'vendor' Directory. Now, you can insert a line:

require_once(__DIR__ .'/package/package.php');

in your project.php File and subsequently use the classes/functions from the imported Package.
And, well, there are also Packages which are not in Packagist, but simply in some other Repository, like GitHub, GitLab etc. - these will just have to be downloaded/extracted to the right Directory.

Ähnliche Beiträge: