Comments (8)
Hey, looks like you are firing the "clockwork.controller.end", without firing "clockwork.controller.start" beforehand. Are you using this feature?
from clockwork.
Yes, of course.
Here is my code of BaseController construct:
$this->beforeFilter('csrf', array('on' => 'post'));
$this->beforeFilter(function()
{
Event::fire('clockwork.controller.start');
});
$this->afterFilter(function()
{
Event::fire('clockwork.controller.end');
});
from clockwork.
I encountered this issue as well, I have this in my BaseController
contructor:
/**
* Create new instance of BaseController
*/
public function __construct()
{
$this->beforeFilter('csrf', array('on' => 'POST'));
$this->beforeFilter('auth', ['except' => 'login']);
$this->beforeFilter(function()
{
Event::fire('clockwork.controller.start');
});
$this->afterFilter(function()
{
Event::fire('clockwork.controller.end');
});
}
Well I just solved this by putting first the clockwork events it looks like this:
$this->beforeFilter(function()
{
Event::fire('clockwork.controller.start');
});
$this->afterFilter(function()
{
Event::fire('clockwork.controller.end');
});
$this->beforeFilter('csrf', array('on' => 'POST'));
$this->beforeFilter('auth', ['except' => 'login']);
from clockwork.
This problem is due to application filters not being registered in the proper order. If I register an App::before()
filter in a service provider before Clockwork's service provider is registered, my filter's closure will run before Clockwork. If my filter returns a response, Clockwork's will never be called, thus never calling startEvent()
.
A solution would be to circumvent registering events using things like $this->app->before()
, and target the direct event you want to register a listener for via $this->app['events']->listen()
(how it's being done in most places already). Then, you'll also want to specify a priority for, at minimum, the early-on listeners (particularly router.before
), which ensures Clockwork's filter(s) run as early as possible, before any user-set listeners.
from clockwork.
thanks!
from clockwork.
@diffmike I would reopen this, as the above solution should be implemented by @itsgoingd / Clockwork, not the user end. I can PR it soon, if desired.
from clockwork.
Ok. It's reopen
from clockwork.
Fixed in dev-master, calling endEvent for non-existing event no longer throws exception, as it's not exceptional enough to tear down the whole app imo.
I would like to capture the controller runtime automatically, without the need to add code to the base controller at all, the closest events to use would be afaik router.matched as controller start time and router.after as controller end time, this would still include route filters runtime though. If you have a better idea feel free to reopen.
from clockwork.
Related Issues (20)
- Unable to Expand Array/Object with Key Starting with Numeric HOT 2
- Symfony 6.3 BC break HOT 11
- Clockwork HOT 1
- commandExecuted - no output in extension HOT 6
- Redis::pipeline calls not being instrumented HOT 3
- Profiler Tab stuck on "Loading profile" HOT 6
- Profiler support when using Slim 4 HOT 1
- Typo in `Request::addModelAction()` HOT 2
- Argument 6 passed to Symfony\Component\HttpFoundation\Cookie::__construct() must be of the type boolean, null given, called in vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkSupport.php on line 438 HOT 6
- Using MonologDataSource trigger error HOT 2
- Store method doesn't work (returns 404) HOT 2
- Compatibility with Doctrine DBAL 3 HOT 1
- (Laravel) Chrome extension has option to "Load more", but the web page doesn't? HOT 1
- Show listeners in events data source HOT 1
- Changed default behavior HOT 3
- Slack Message Notification tries to access protected property HOT 5
- Serialization Failure in Clockwork Due to Incomplete Object Representations HOT 5
- Bug: Exception when Notification class missing toArray() method HOT 2
- Symfony 7 Compatibility issues HOT 3
- Where is the response in this? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clockwork.