Closed arubacao closed 8 years ago
I think this would work better as a separate package which provides the service provider, it can require this package as a dependency. That's what we did with Symfony.
@arubacao, you can create a service provider to ensure this package works with Lumen:
<?php
namespace App\Providers;
use Maknz\Slack\SlackServiceProviderLaravel5;
class SlackServiceProviderLumen extends SlackServiceProviderLaravel5 {
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot() {
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register() {
$this->mergeConfigFrom(base_path() . '/config/slack.php', 'slack');
parent::register();
}
}
And in bootstrap/app.php
:
$app->register(\App\Providers\SlackServiceProviderLumen::class);
You may need to manually copy the config file to /config/slack.php
in your project directory.
Have been thinking hard on this. I haven't dealt with Lumen much, but from my research it's not really intended to be used with packages like this (in terms of Laravel integration). There's no mechanism for publishing config (because the goal of the framework is to be lightweight), and facades are implemented with class_alias
manually, and isn't a first-class feature. Lumen seems to be a very different framework to Laravel.
So I think if someone wants to use Lumen, they can try the solution above, but I don't think it's something we can provide a good integration for.
I agree with Lumen being more lightweight that Laravel, but still, it's powered by Laravel components so they are more or less identical.
Check out the official docs of Lumen
Lumen 5.2 represents a shift on slimming Lumen to focus solely on serving stateless, JSON APIs. As such, sessions and views are no longer included with the framework. If you need access to these features, you should use the full Laravel framework. Upgrading your Lumen application to the full Laravel framework mainly involves copying your routes and classes over into a fresh installation of Laravel. Since Laravel and Lumen share many of the same components, your classes should not require any modification.
I've just create a own class, extended \Maknz\Slack\Client
and pass my credentials and settings through.
class Slack extends \Maknz\Slack\Client
{
public function __construct()
{
$config = config('services.slack');
parent::__construct($config['webhook'], $config['settings']);
}
}
Not having a publish method out-of-the-box doesn't mean you can't just copy the necessary files ;) In my opinion, a Laravel package (even though this isn't exclusively a laravel package) should also have a Lumen service provider, it's just more convenient than a workaround :)
So the library supports Lumen just like Laravel