Call to undefined method Illuminate\Foundation\Application::share() when use breadcrumbs package - php

Today, I want to use Laravel Breadcrumbs package with laravel 5.4. I used that with laravel 5.3 without any problem and all things worked fine.
But when run the application I got this error :
FatalErrorException in ServiceProvider.php line 34:
Call to undefined method Illuminate\Foundation\Application::share()
I searched for that and I found that As of laravel 5.4 share has been removed. and I must to use the singleton instead.
But when I did that changes In the ServiceProvider.php like this :
public function register()
{
$this->app['breadcrumbs'] = $this->app->singleton(function($app)
{
$breadcrumbs = $this->app->make('DaveJamesMiller\Breadcrumbs\Manager');
$viewPath = __DIR__ . '/../views/';
$this->loadViewsFrom($viewPath, 'breadcrumbs');
$this->loadViewsFrom($viewPath, 'laravel-breadcrumbs'); // Backwards-compatibility with 2.x
$breadcrumbs->setView($app['config']['breadcrumbs.view']);
return $breadcrumbs;
});
}
I got another error. like this :
ErrorException in Container.php line 1057:
Illegal offset type in unset
I do not know what is problem. can anyone help me ?
Update :
I found the solution Here.

The first problem is that the singleton instance expects a class to bind to as the first argument, which in this case is 'breadcrumbs'.
The second problem is that you don't need to explicitly declare the array key for the singleton instance. So this is how it should look:
$this->app->singleton('breadcrumbs', function($app)
The next problem is that the package you're using has been abandoned. The developer will no longer maintain it.
The final problem is that you're using a version < 3.0.2. So change the version in your composer.json to 3.0.2 and then install that, then you shouldn't need to be modifying any files.

Related

Call to undefined method GetStream\\Stream\\Feed::followFeed()

I am using getstream in laravel project. When calling followUser method of StreamLaravelManager class, it does not find followFeed method inside the package. What may be the problem here?
\FeedManager::followUser($follower->follow_id, $follower->user_id);
Above line of code is triggering the method.
I donot know what might be wrong here, but changing the get stream version solved this issue. Changed "get-stream/stream-laravel": "^2.2" to "get-stream/stream-laravel": "~2.2.6" in my composer and it solved . the issue.

Smfony2: Getting an error when trying to use translatble behavior extension

I am trying to use translatable behavior in my project, I followed the doc word by word to how configure and use this behavior , but I am getting this error:
CRITICAL - Uncaught PHP Exception ReflectionException: "Property locale does not exist" at C:\wamp\www\Symfony\vendor\gedmo\doctrine-extensions\lib\Gedmo\Translatable\TranslatableListener.php line 296
Can anyone help please?
Thanks in advance :)
Edit:
This is the line 296:
$reflectionProperty = $class->getProperty(self::$configurations[$this->name][$meta->name]['locale']);
In my case the required $locale field was defined in an abstract super class of the entity - which is basically fine, however it must not be private but at most protected.

Fatal error: Call to undefined method Google_IO_Curl::authenticatedRequest()

When using the described in the Google Contacts API example simple.php, and the Google API PHP Client from GitHub, version 1.0.4-beta, I get the following error:
Fatal error: Call to undefined method Google_IO_Curl::authenticatedRequest()
However, when I change this line...
$val = $client_svc_contacts->getIo()->authenticatedRequest($req);
...to...
$val = $client_svc_contacts->getAuth()->authenticatedRequest($req);
...then it starts working again.
I am using version 1.0.4-beta unmodified except for the addition of the following line at the top of Client.php:
set_include_path(str_replace('/Google','',dirname(__FILE__)));
I recognize that simple.php was written for version 0.6, not v1+, but is the example just out of date compared to the version on GitHub? Or is there something wrong with my implementation?
Found a migration guide that had the answer ...
A new home for authenticatedRequest
The authenticatedRequest method has been moved from the io classes to
the auth classes.
So it appears that replacing getIo() with getAuth() was the correct course of action.

CakePHP: Fatal error: Call to a member function image()

I'm using the following Helper: http://pastebin.com/qBs2GvG4 in my CakePHP 2.0 app to show a gravatar for a user like so:
<?php $this->Gravatar->image($profile['User']['email'], array('default'=>'mm','size'=>48)); ?>
However it gives the error:
Fatal error: Call to a member function image() on a non-object in /Users/cameron/Sites/social/app/View/Helper/GravatarHelper.php on line 97
Any ideas what the problem is? This worked in my 1.3 app so wondering if something has changed between 1.3 and 2.0 that causes this issue? Thanks
Helpers have slightly different dependencies in 2.0, especially if they require other helpers.I actually made the commits to fix this one in the CakeDC utils plugin.
You can find an updated version of that helper here: https://github.com/CakeDC/utils/blob/2.0/View/Helper/GravatarHelper.php
Looks like the GravatarHelper has a dependency on the HtmlHelper. Is Html in your list of helpers in the controller?

Fatal error with Custom Magento Module on one server but not the other

I am creating my own custom module in Magento and during testing on a Litespeed server (PHP v5.2.14) I am getting a Fatal Error: Call to a member function batch() on a non-object in ../../../BatchController.php on line 25 that was not appearing during testing on another linux server and a wamp server (PHP v5.2.11).
This one has stumped me. I am guessing it has something to do with the server configuration rather than the code itself. But i am just guessing. I was hoping someone here could tell me.
The only real major difference I could see, aside from the php versions and environment, is that the server that the error is on is using the Suhosin Patch. But would that be something that could cause this?
The line in question is Mage::getModel('mymodule/mymodel')->batch(); which is enclosed in an IF statement. batch() is a public function located in my model file.
If you need more code let me know.
Thanks!
If you get a "non-object" error when calling a model, there's a problem with Magento's attempt to get your model class, and it is returning null. The reasons for this are not always apparent. If this worked identically on a normal LAMP stack, then the problem is most likely not in your code.
My first guess would be that the file does not have the proper permissions. Otherwise, it may have to do with resolving the classname. You could test this temporarily by calling the plugin directly like this:
$obj = new Mynamespace_Mymodule_Model_Mymodel();
$obj->batch();
If this works, then the file is readable, and you will want to go spelunking in the resolution of that classname. If it doesn't work, you have a problem with either autoloading or the declaration of your class.
Hope that helps!
Thanks,
Joe
Break it down.
You've tried to call
Mage::getModel('mymodule/mymodel')->batch();
and PHP told you it tried to call the method batch on a non-object. That means
Mage::getModel('mymodule/mymodel')
isn't returning a Model object the way it's supposed to.
First thing to do is clear out your Magento cache on the server you're having problems with. If your Module's config hasn't been loaded into the global config tree Magento will try to instantiate a Mage_Core_Model_Mymodel, and fail.
Second step is to make sure your module's app/etc/module file is in place.
Third step is to add some debugging (assuming a 1.4 branch) to the method that instantiates your objects and determine why Magento can't create your object
File: app/code/core/Mage/Core/Model/Config.php
...
public function getModelInstance($modelClass='', $constructArguments=array())
{
$className = $this->getModelClassName($modelClass);
if (class_exists($className)) {
Varien_Profiler::start('CORE::create_object_of::'.$className);
$obj = new $className($constructArguments);
Varien_Profiler::stop('CORE::create_object_of::'.$className);
return $obj;
} else {
#throw Mage::exception('Mage_Core', Mage::helper('core')->__('Model class does not exist: %s.', $modelClass));
return false;
}
}
...

Categories