laravelmodelrepository-design

Laravel App::make causes infinite loop


I'm creating some project management functionality.

I'm using Model Observers in Laravel to create an audit trail whenever models are created/updated/deleted. So for example when a project is created, the observer will automatically create a new instance of the project audit model creating a new database entry storing the fields that have changed. This observer also clears the relevant caches, ensuring the user can access the most recent information.

The problem is calling the cache repository causes this error message (with no stack trace):

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Maximum function nesting level of '100' reached, aborting!

I'm using App::make to call the cache repository:

$this->projectAuditCache = App::make('cache\ProjectManagement\Interfaces\ProjectAuditCacheInterface');

The Audit Cache Repository then constructs with only one other repository which isn't reliant on anything else.

The only possible clue on the stack trace is this:

Open: /home/vagrant/Sites/fixing/new_fixing/vendor/laravel/framework/src/Illuminate/Container/Container.php
     * Determine if the given abstract has a leading slash.
     *
     * @param  string  $abstract
     * @return bool
     */
    protected function missingLeadingSlash($abstract)
    {
        return is_string($abstract) && strpos($abstract, '\\') !== 0;
    }

Is there a way to get this to work? Is using App::make the wrong way to go about this?

Thanks, Ed


Solution

  • The problem which causes the error is xdebug the debug extension of PHP. The array that this extension wants to echo is to big.

    You can just simply adjust the setting of maximum nesting level of xdebug simply in your php.ini. Or with the command

    ini_set('xdebug.max_nesting_level', $limit)
    

    which should be included when your app starts. For Laravel 4.x that would be app/start/global.php.

    Source: StackOverflow