Apps
Introduction
Apps can extend the functionality of your sites. These can be pulled in via Composer.
1composer require astrogoat/klarna
Available Apps
Creating Your Own App
You can fairly easily create your own app to extend functionality in Strata. The quickest way to get started is by using the GitHub app-skeleton template repository.
- Press the "Use template" button at the top of the repo to create a new repo with the contents of the skeleton.
- Run
php ./configure.php
to run a script that will replace all placeholders throughout all the files. - Have fun creating your package.
Registering your app
Within your SkeletonServiceProvider.php
(this has likely be named to YourAppNameServiceProvider.php
) you can hook into Strata and register your app:
1use Helix\Lego\Apps\App; 2use Helix\Lego\LegoManager; 3use VendorName\Skeleton\Settings\SkeletonSettings; 4 5public function registerApp(LegoManager $strata) 6{ 7 $strata->registerApp(function (App $app) { 8 return $app 9 ->name('skeleton')10 ->settings(SkeletonSettings::class);11 });12}
Here we are registering the app, giving it a name and defining the settings that should go along with it.
All apps needs a settings class that extends the base
AppSettings
class.
Developing locally
It's often times much easier to develop the Strata app locally then having to push up every little changes to git and then do a Composer update in your main application in order to test out your changes. Composer makes it very easy to overcomes this.
In your main applications composer.json
file you need to specify the local path to the Strata app you're working on.
1"repositories": [2 {3 "type": "path",4 "url": "/Users/tonning/Code/packages/astrogoat/my-app"5 },6],
Then you can pull it in like normal with:
1composer require astrogoat/my-app
But this time Composer will symlink the library to your local path instead of pulling it down.
Settings
All apps need to have a "Settings" class that extends Helix\Lego\Settings\AppSettings
.
This is settings class is registered in the service provider
1$this->callAfterResolving('lego', function (LegoManager $stratum) {2 $stratum->registerApp(function (App $app) {3 return $app->name('skeleton')4 ->settings(SkeletonSettings::class); 5 })6});
Register the App with Packagist.org
When you feel your Strata app is done and tested, then it's a good idea to register the app on packagist.org and set it up with auto-updating so it's easy to pull it down with Composer.