Comments (7)
This package is for use with Laravel. You should use it as described in the README (and in the tests).
Add the Share facade to config/app.php, and use it.
You're trying to create the Chencha\Share\Share class directly, instead of using the Share facade (Chencha\Share\ShareFacade).
PS: $app is the Laravel app, if you want to see the Share class being created, look in the Chencha\Share\ShareServiceProvider class.
from social-share.
As an aside, are you wanting to try use this outside of Laravel? I could get the package to support that. It currently uses Laravel for other things like templating, config (and possibly translation), but I could make a plan to separate those parts out, so it can be used with or without Laravel.
from social-share.
Hi. I see what you mean about the service provider passing the $app param. So I'm trying to do it the way you describe, using the facade. Here's what I have:
config/app.php
// Added to providers array
Chencha\Share\ShareServiceProvider,
// Should it be Chencha\Share\ShareServiceProvider::class,?
// Added to aliases array
'Share' => Chencha\Share\ShareFacade,
// Should it be 'Share' => Chencha\Share\ShareFacade::class,
I'm using laravel 5
If I try to use the face, I get the following error:
// I'm using it inside a model, so $this->title and $this->slug are present
$this->social = Share::load('http://domain.com/'. $this->slug, $this->title, $this->title )->services();
Non-static method Chencha\Share\Share::load() should not be called statically, assuming $this from incompatible context
Thank you for your reply, I appreciate it.
from social-share.
You're again using the wrong class. Do not use Chencha\Share\Share directly. Adding an alias to config/app.php adds a global class called Share. Try use Share instead.
from social-share.
I don't see how I'm using the Chencha\Share\Share class directly.
I've added the alias and registered the service provider, the class doesn't seem get registered.
Thank you for your help, I've written the share urls into the model directly.
from social-share.
If you are using PHPStrom, It is not auto importing the alias. I don't know why but It imports the Class from original package instead from the alias.
I faced the same problem and it gets resolved when I changed the 'use Chencha\Share\Share' to 'use Share'. Doing this uses the alias we wrote on app.php. And things will work.
from social-share.
This might help you, @scvishnu7 https://github.com/barryvdh/laravel-ide-helper
from social-share.
Related Issues (20)
- Download via composer doesn't work HOT 2
- How to pass media url for Pinterest? HOT 3
- Is it possible to support the Instagram provider? HOT 2
- FatalThrowableError in ShareController.php line 30: Class 'Share' not found
- Add config with laravel 5.6 HOT 1
- Customise this package for blogger
- Can't install on clean Laravel 6 HOT 8
- Call to undefined function Chencha\Share\array_get() HOT 1
- Documentation Improvement HOT 1
- Non-static method Chencha\Share\Share::load() should not be called statically HOT 1
- Laravel 7.0 HOT 2
- The 5.4.1 tag is not accessible trough packagist.org / composer HOT 3
- LinkedIn share link not working
- The package is not auto updated on packagist.org HOT 2
- This package in not installing in laravel 7 HOT 2
- Not working with Laravel 7+ HOT 4
- Class 'Arr' not found error with laravel 7.0 HOT 1
- On Linkedin and Facebook not showing Text
- Laravel 8 Support HOT 2
- Issue in default.blade.php on Laravel 6 HOT 3
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 social-share.