Git Product home page Git Product logo

Comments (7)

datashaman avatar datashaman commented on September 17, 2024

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.

datashaman avatar datashaman commented on September 17, 2024

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.

javiermar avatar javiermar commented on September 17, 2024

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.

datashaman avatar datashaman commented on September 17, 2024

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.

javiermar avatar javiermar commented on September 17, 2024

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.

scvishnu7 avatar scvishnu7 commented on September 17, 2024

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.

datashaman avatar datashaman commented on September 17, 2024

This might help you, @scvishnu7 https://github.com/barryvdh/laravel-ide-helper

from social-share.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.