1. Go to this page and download the library: Download tormjens/eventy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Fire a filter
apply_filters('my.hook', 'awesome');
class PostsQueryBuilder
{
public function query()
{
return Post::where('published_at', '>', now());
}
}
use TorMorten\Eventy\Facades\Events as Eventy;
class PostsQueryBuilder
{
public function query()
{
$query = resolve(Post::where('published_at', '>', now());
return Eventy::filter('posts-query-builder:query', $query);
}
}
use TorMorten\Eventy\Facades\Events as Eventy;
class PluginBServiceProvider extends ServiceProvider
{
public function boot()
{
Eventy::addFilter('posts-query-builder:query', function($query) {
return $query->where('title', 'like', '%foo%');
});
}
}
use TorMorten\Eventy\Facades\Events as Eventy;
class SharePostsController
{
public function boot()
{
Eventy::addAction('blade-posts-loop-post-footer', function($post) {
echo '<a href="twitter.com?share='.$post->url.'">Twitter</a>';
printf('<a href="https://xyz.com?share='.$post->url.'">XYZbook</a>');
});
}
}
use TorMorten\Eventy\Facades\Events as Eventy;
class CommentsPostsController
{
public function boot()
{
Eventy::addAction('blade-posts-loop-post-footer', function($post) {
echo 'Comments: ' . count($post->comments);
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.