tormjens / eventy Goto Github PK
View Code? Open in Web Editor NEWWordPress-like actions and filters for Laravel
WordPress-like actions and filters for Laravel
Hi,
After installing by composer I receive this error.
Package jeremeamia/superclosure is abandoned, you should avoid using it. Use opis/closure instead.
https://github.com/tormjens/eventy/blob/master/src/HashedCallable.php#L27
The id
is the signature
.
Hello, sir,
Thank you for this package. It's really great. So, I'm trying to explore the possibility that whether I can use it in my project. It's a CMS, and without Laravel, or composer.
I think the core of Eventy is mature enough so that it can be independent from Laravel. I think the core of Eventy does not need the two provider classes, or the Facades directory, does it ? since they are Laravel-specific. If I don't use it in Laravel, I don't need them. Is it possible?
And in the HashedCallable
class, can we use other way to replace the Laravel SerializableClosure
? I mean, with a simple way, not using another package. But if we really have to use Laravel SerializableClosure
, I think it's okay, since the package Laravel serializable-closure has zero dependency. I just add it to the vendor along with your excellent Eventy. But I really hope we can replace it with another simpler way to serialize callbacks.
Could you help me answer these questions? Thank you.
This is a very wonderful package. Does it support laravel 8?
Hey, firstly very awesome package!
I've got a project that is running the Lumen v5.3 and I'm currently having to manually include the eventy package files into my project because of the 5.5 illuminate/support
requirement.
I'm curious if you see any issues with decreasing the requirement from 5.5 as it appears to work fine on 5.3 (i could be missing something)
I would be happy to push up a patch to reduce the requirement to 5.3, if you okay with it, I can also push up some notes on installation for Lumen (different steps required to the ones in your readme)
Hi I use vanilla php sometimes is there any way to get this working without laravel, or do you know any other alternative?
Hey there,
I've just installed via composer and it's pulling down 0.5.1, which doesn't include EventBladeServiceProvider.php.
Could you possibly push 0.5.2 to Packagist so we can pull from composer ๐
Cheers
The package is very good. I tested it in Laravel 10 but it gives following error.
"A facade root has not been set."
Will the package be updated for this version?
hi:
Eventy::addAction('app_admin_assets', '_maybe_init_admin_project_assets', 5);
function _maybe_init_admin_project_assets()
{
echo 'hi';
}
get error:
Target class [_maybe_init_admin_project_assets] does not exist.
I, too, come from the WordPress world, so this project is perfect for me.
What I'm struggling with is trying to figure out how I might build a plugin system around this. I still haven't nailed down the Laravel execution path. Would I need to create a service provider and load it prior to the Eventy providers?
First off, good work on the package! It's one of the better bits of Wordpress and you've made it really easy to use.
I do have a small issue though. Currently I can pass a closure:
Eventy::addAction('foo', function() {
echo 'bar';
});
...or a string
Eventy::addAction('foo', 'someClass@baz');
...but I can't pass a callable array:
Eventy::addAction('foo', [$this, 'bar']);
This would be really helpful as it would allow me to access the current scope of $this
which processing the action.
This could be achieved by updating the Event
getFunction
method to the following:
protected function getFunction($callback)
{
if (is_string($callback) && strpos($callback, '@')) {
$callback = explode('@', $callback);
return array(app('\\' . $callback[0]), $callback[1]);
} else if (is_callable($callback)) {
return $callback;
} else {
throw new Exception('$callback is not a Callable', 1);
}
}
If this looks good to you I can submit a pull request.
Cheers!
Hi .
i installed this package on my project . i used laravel 5.7 .
first i didnt set facade and providers in app.php and i tryed to use from Eventy facade. but didn
t work .
then i set facade and providers in app.php but didn`t work again .
or
then when i used Eventy::action i see this error :
please help me .
thanks
When I tried to register more than one action with the same priority, just on of them "The last one" is registered and override the others.
I have a gut feeling that this tool is something very useful, but I do not know what is action and filter in Wordpress, as I never learnt Wordpress, can someone update the document/readme to give more generic explanation or use case about, how these actions and filters can be used in a Laravel project.
Thank you for all your hard work on this, I'm really excited about using it in a future project.
As someone very new to Laravel I'm reluctant to open this ticket, however as a WordPress developer (for ~15 years) I feel obligated to mention the differences between "actions" and "filters" isn't demonstrated well within the examples, since they're practically the same.
I'd suggest passing variables in hooks, otherwise it's just a filter. This would help not only with differentiate the two but show the power of creating an action hook.
use TorMorten\Eventy\Facades\Events as Eventy;
Eventy::action('my.hook', $user);
Eventy::addAction('my.hook', function($user) {
if ($user->is_awesome) {
$this->doSomethingAwesome($user);
}
}, 20, 1);
Especially in regards to templating.
@action('my.hook', $user)
@action('my.hook')
Maybe an example you can use for "Using it to enable extensibility".
Here's an example of an action being added to the a blade template for extensibility by plugins that can be conditionally loaded.
@foreach ($posts as $post)
...
<p>{{ $post->body }}</p>
...
@action('blade-posts-loop-post', $post)
@endforeach
use TorMorten\Eventy\Facades\Events as Eventy;
class SharePostsController
{
public function boot()
{
Eventy::addAction('blade-posts-loop-post', function($post) {
echo '<a href="'.$post->url.'">Share this post</a>';
printf('<a href="https://xyz.com?share='.$post->url.'">Share this post</a>');
});
}
}
use TorMorten\Eventy\Facades\Events as Eventy;
class CommentsPostsController
{
public function boot()
{
Eventy::addAction('blade-posts-loop-post', function($post) {
echo 'Comments: ' . count($post->comments);
});
}
}
If one of the parameters passed to \Eventy::filter()
(or 'action()') is null
you will get "Too few arguments..." error:
\Eventy::addFilter('filter_name', function($test1, $test2) {
return $test1;
}, 20, 2);
$test1 = 1;
$tes2 = null;
\Eventy::filter('filter_name', $test1, $test2);
When i add a action:
Eventy::addAction('foo', function() { echo 'bar'; });
Then I want to remove it, How to do this?
Eventy::remove('foo', โฆโฆ);
Class 'TorMorten\Eventy\Exception' not found in Event.php line 62
Looks like you either need to use Exception;
or throw new \Exception
I'd submit a pull request but I'm right in the middle of something.
First of all, thank you so very much for this wonderful package..
What i would like to know now is, does this packages support queue?
Secondly it seems most of my application logic would reside in service-provider or is there something I'm not getting.
I await your humble clearance,
Thanks in advance
Is it possible to use this package without Laravel Framework?
I want to use it with Slim Framework.
How can I do this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.