Comments (5)
Although in this comment we made a decision to support:
$pusherConfig = new Config('https://key:[email protected]/apps/1234');
$pusher = new Pusher($pusherConfig);
I don't think it's the right decision. I don't see the need to expose a Config
class that doesn't add any value to the public API.
We could update the constructor to support:
$pusher = new Pusher('https://key:[email protected]/apps/1234');
But then where do options parameters get added since the 2nd and 3rd are usually the appKey
and appSecret
.
Thus, I would opt to keep the 1st parameter as the application ID only when using new Pusher
and go with a dedicated factory function (this issue) when using this interesting URL initialisation:
$options = [];
$pusher = Pusher::forUrl('https://key:[email protected]/apps/1234', $options);
This also aligns with the Node library:
https://github.com/pusher/pusher-http-node/blob/master/lib/pusher.js#L62
Any objections or additional thoughts?
from pusher-http-php.
Well there will be a Config class that's exposed, so whether we have the forUrl()
method or not, that api will still exist. It's just a case of whether we advertise this in the documentation.
And obviously we've already regressed the new Pusher('https://key:[email protected]/apps/1234');
so it doesn't make sense to go back down that road. I'm happy for using this static factory method, but as long as it's not some other variation of the old singleton factory method (Pusher::instance();
).
from pusher-http-php.
I've had a dig into this and it's a bit of a rabbit hole. The Config
class does a few things that probably need refactored:
- You can't create a new
Config
instance with thekey:secret
URL and also pass in additional options that aren't represented in the URL e.g. debug/logger, proxy - It supports app key/secret pairs which we don't need. This was actually also in the Python library and we took it out before release
My personal preference right now would be to move this issue to a 3.1 milestone and create a fix issue (or re-open #66) for 3.0 in order to remove support for the first parameter of the Pusher
constructor (appId
) being a Config
instance.
3.1 will then include:
- support for
Pusher::fromUrl($url, $options)
(this issue) - remove key pair support from
Config
- Refactor URL parsing so it can be used outside of the
Config
class or maybe$config = Config.fromUrl($url)
- Update
Config
constructor to only supportnew Config($options)
or maybe it should align with thePusher
constructor:new Config($appId, $appKey, $appSecret, $options)
Putting all this together should allow a cleaner solution to this issue than the rabbit hole I mentioned. This is just an off the top of my head and there may be a more elegant solution:
class Pusher {
public static function fromUrl($url, $options) {
$config = Config::fromUrl($url);
$pusher = new Pusher($config->appId, $config->appKey, $config->appSecret, $options);
return $pusher;
}
}
Does anybody object to removing support for new Pusher($configInstance)
in 3.0? The main problem I can think of is that it supports Heroku's preferred key:secret
URL method. But I don't believe too many developers a) use PHP on Heroku b) use a non-US cluster on Heroku c) Have needs for a & b
from pusher-http-php.
I had a look at this but am unsure in what file to put that function. If we're following PSR-4 the only way to have a Pusher::fromUrl()
function to be auto-loaded would be to define a top-level Pusher class.
from pusher-http-php.
Nevermind, I'll follow what Guzzle does: https://github.com/guzzle/guzzle/blob/master/composer.json#L26
from pusher-http-php.
Related Issues (20)
- Echo.listen not working in pusher-php-server 7.2.1 HOT 2
- Upgrading from 7.0.2 to 7.2.0 breaks broadcasting events in laravel HOT 5
- Pusher error: cURL error 28: Failed to connect to api-eu.pusher.com port 443: Connection timed out HOT 7
- Invalid user id from pusher server. HOT 2
- The CI setup is not friendly to community contributors HOT 1
- Add the ability to set Guzzle config from $options HOT 3
- v7.2.1 is not compatible with pusher SDK HOT 5
- Batch message sending does not add socket_id from event HOT 6
- Internal Server Error 500 HOT 2
- Pusher Beams Enquiry HOT 23
- Reporting a vulnerability HOT 1
- Pusher being run at Laravel package:discover resulting in Argument Error HOT 7
- Pusher Presence Channel Data HOT 1
- First parameter must either be an object or the name of an existing class {"exception":"[object] (ErrorException(code: 0) HOT 2
- Question about deprecation for all of the versions above v13 HOT 1
- [bug] cannot set a custom timeout as a option in pusher
- Triggering single event on multiple encrypted channel fails HOT 1
- Pusher websocket URL triggering events and sending data HOT 1
- You MUST recompile PHP with a larger value of FD_SETSIZE. It is set to 1024
- How to Properly Handle json_decode Error with Guzzle Stream in Pusher Library?
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 pusher-http-php.