Just a quick one, I’ve just updated the Known dev tools with a new script – plugin.php.

There’s currently only one function available enable-composer which, following my last post, provides a handy script for making your plugin composer installable.

Run the script, passing it the repository you’ve saved it as (so that the script can set the packagist headers correctly), and you’ll get an updated / new composer.json with all the appropriate values set.

You can optionally set whether the plugin is a straight plugin, theme or console plugin (known-plugin is default). You can also target directories other than the current directory, although realistically you’re never really going to run it from any other directory.

Enjoy!

» Visit the project on Github...

So, I’m delighted to say that what I consider to be an important landmark towards Known 1.0 has been reached, and that is that Composer Installers now supports Known plugins, themes and console plugins!

Currently support is only available in the development build, but support now should be included in the next release, which will hopefully come out soon!

This is a big deal for two important reasons; firstly it now becomes super easy to roll your own builds of Known, by simply supplying your own composer.json, and second, it solves the frustrating “checkout repository, move and rename” problem.

Making your plugin Composer ready

If you’re a plugin developer, there’s a few things you need to do in order to take advantage of this:

Create a composer.json file

Firstly you need to create a composer.json file. This file can contain a bunch of things, but at the very least you need to give your package a name, a version, and include the relevant composer installers instructions.

Here’s an example from my IPFS plugin, with the important parts in bold.

{
"name": "mapkyca/known-ipfs",
"type": "known-plugin",
"description": "Adds IPFS support to Known",
"version": "0.1.4",
"homepage": "https://www.marcus-povey.co.uk",
"keywords": [
"known",
"plugin",
"ipfs"
],
"license": "GPL-2.0",
"authors": [
{
"name": "Marcus Povey",
"email": "marcus@marcus-povey.co.uk"
}
],
"require": {
"php": ">=7.1",
"cloutier/php-ipfs-api": "^0.0.6",
"composer/installers": "~1.0"
},
"extra": {
"installer-name": "IPFS"
},
"require-dev": {
"mapkyca/known-language-tools": "^1.0",
"mapkyca/known-dev-scripts": "^1.0",
"mapkyca/known-phpcs": "^1.0"
}
}
  • name: the name of the repository (used for packagist)
  • type: should either be known-plugin known-console or known-theme
  • version: version of the plugin, again for packagist
  • “composer/installers”: “~1.0” in require composer your plugin needs to require the installers plugin. This is also included by Known core, so don’t worry too much if you forget!
  • “installer-name”: “IPFS” this tells installers that your plugin should be installed in the named directory. So in this case instead of installing the plugin as the repo name (known-ipfs), it’ll install as ‘IPFS’. This is of course the correct plugin name according to its class hierarchy… so no more renaming!

Create a tagged release

Write your code, and then create a tagged release matching the version value in your composer.json.

Submit to packagists.org

Finally, submit your plugin to packagists.org in order to make it available for other Known installations to use!

Enjoy!

So, another quick one.

I had the need to test something out in Known around OAuth2 “sign in as” buttons, so I put together a very quick, and generic, client for it.

This is very early days and was really written to implement an MVP proof of concept thingy for a client of mine. However, it could be more widely useful and with a bit of work could be handy for folk.

Installation

  • Check it out
  • Run composer install to get the various libraries
  • Put it in your IdnoPlugins directory as OAuth2Client
  • Activate in your plugins

Usage

Go to the admin page and create your new buttons by filling in the appropriate details.

Out of the box this plugin WON’T fully log you in as whatever, you need to write your own handler plugin to listen to the oauth2/authorised event hook.

This hook is passed an array containing the access token and other details for your to use to match up with a user, or create a new one.

If the hook goes unanswered, the plugin will look for id or username in the return JSON.

» Visit the project on Github...