Open SammyK opened 8 years ago
Wow, there are a lot of good changes here!
Require PHP 5.6; 5.5 EOL is July 10th!!
I'm confused only about this point, outside the EOLs and the dependencies' required PHP version what is the reason? Are there any PHP 5.6+ features those could improve the codebase? If yes than it's great, otherwise I'm a bit against this.
My only suggestion is to include a log system (possibly based on PSR-3) for the requests and the API requests debugging.
since this is a major version change, i'm all for switching to a v5.6 requirement.
what's the thought behind removing multiple exceptions and switching to just one? while there could be one parent FacebookException
class, it's nice to have more descriptive children so we have more granularity in the things we catch and how we deal with them.
thanks!
facebook/graph-sdk
I'll think of other ideas when I have time :)
outside the EOLs and the dependencies' required PHP version what is the reason?
EOL means that version of PHP no longer gets updated - for both bug fixes or security issues. So the reason for the upgrade is to ensure the SDK can't be exploited on an old known security hole in an old version of PHP. Plus 5.6 has some TLS improvements that will be helpful for the SDK. :)
what's the thought behind removing multiple exceptions and switching to just one?
The idea would be we could have just two:
FacebookSDKException
: When a general error is generated from within the SDKFacebookResponseException
: When an error response from the Graph API is returnedThis is the same as v5 but in v5 FacebookResponseException
does a lot of parsing in order to best-guess a sub exception to throw as a "previous exception". It makes the API cumbersome especially when you want to figure out specifically what happened:
try {
$me = $fb->get('/me');
} catch(FacebookResponseException $e) {
if ($e->getPrevious() instanceof FacebookAuthenticationException) {
if ($e->getCode() == 10 || ($e->getCode() >= 200 && $e->getCode() <= 299)) {
// Missing permissions
} else {
// General authentication failure
}
} elseif ($e->getPrevious() instanceof FacebookResumableUploadException) {
//
} elseif ($e->getPrevious() instanceof FacebookThrottleException) {
//
} elseif ($e->getPrevious() instanceof FacebookClientException) {
//
}
}
Whereas the API to find the specific error could be made more clear:
try {
$me = $fb->get('/me');
} catch(FacebookResponseException $e) {
switch ($e->getType()) {
case FacebookResponseException::AUTHENTICATION_FAILURE;
//
break;
case FacebookResponseException::MISSING_PERMISSIONS;
//
break;
case FacebookResponseException::RESUMABLE_UPLOAD_FAILURE;
//
break;
case FacebookResponseException::THROTTLE_LIMIT_REACHED;
//
break;
case FacebookResponseException::DUPLICATE_POST;
//
break;
}
}
So you get even more specificity with a cleaner API. :)
@yguedidi
1) Ooh! Yes, HTTPlug is much better. :)
9) Explained above
12) I'd love to hear your thoughts on improving these. I'd be inclined to just offer a general Collection
that all the responses are returned in with some methods to access meta data as collections as well. It would remove a lot of code and makes the API simpler. I'm just seeing a bit of confusion around the internet about when to use the getGraphNode()
vs the getGraphEdge()
method. :)
15) Love it!
@SammyK
9) The problem comes because the fact exception are "previous", but they aren't: an authentication failure is a Graph response exception.
I think FacebookResponseException
should be a parent class that maybe can be a factory for all its child classes.
Then:
try {
$me = $fb->get('/me');
} catch(FacebookAuthenticationFailureException $e) {
//
} catch(FacebookMissingPermissionsException $e) {
//
} catch(FacebookAuthenticationException $e) {
// generic authentication exception
} catch(FacebookResumableUploadException $e) {
//
} catch(FacebookThrottleException $e) {
//
} catch(FacebookClientException $e) {
//
} catch(FacebookResponseException $e) {
// generic exception
}
Clearer isn't it? :)
Yeah, that's certainly better. I'm just not a fan of throwing a separate exception for every possible error response. But that's just a preference thing so I'll go with whatever the majority want. :)
@SammyK with this, the user can choose exactly which exception he/she want to catch. Imagine you want to catch only the missing permission error, with your code you'll need to first catch, and then check for the type. :)
Makes sense. :)
When we start :) ?
@tolbon Haha! Good question. :) I guess the first step is set up the repo for a merging strategy.
@yguedidi If I remember correctly from the last major upgrade. We make master
v6 and create new branch 5.0-dev
and make it default. Then set up a branch alias in composer.json
to point dev-master
to that branch? Although I'm realizing that line already exists. Yikes! But does that sound about right? Then I guess we could just start pushing v6 through. :)
@SammyK I create two new branches:
5.1
based on 5.1.5
for bugfixes in that minor version5.2
based on 5.2.0
for bugfixes toomaster
will be used for 6.0
developmentAny bugfix must go in the lowest affected branch, then we will have to merge the fixed branch with it's newer one.
What do you thing about this?
3) NO.. not everyone uses composer. It should not be required.. Personally I hate seeing that crap everywhere ;)
Composer is the de facto package dependency manager for PHP, so we will only support this installation method. If you don't want to use composer, you will always be able to download the zip file and write your own autoloader :)
so we will only support this installation method
Why? Autoloader is already there. Why not give the user the option, like it is now?
Isn't the point of the SDK's to have the needed code written for the Dev's so they don't have to write it!?
Hey @Kastlebrick! The latest version of the SDK will be pulling in dependencies with composer so even if you write your own autoloader, it would need to include those dependancies.
Is there a specific reason why you're against using composer? :)
@Kastlebrick
Isn't the point of the SDK's to have the needed code written for the Dev's so they don't have to write it!?
It isn't! Even a framework will not write your business logic for you :)
BTW, I'm curious about the reason why you don't like composer..
@SammyK Never used it, don't have it, and it's one less thing I would have to install and maintain on my server.
@yguedidi I think the point I am trying to make is that the SDK should be self contained. And I/we shouldn't have to rely on some other 3rd party code just to make it work. Yes I 'write the business logic', but (in a nutshell) the Autoloader simply loads what is needed for the SDK so I can make that connection to FB.
I really don't want to argue semantics, but what you call 'good practice' I call bad. If you feel it's good to offer the option to use composer, then at least to both.. and don't require it.
I guess, in the end, you will do what you want.. and this is just my two cents, but I don't understand why you would require and rely on some other 3rd party just to make your code work (when it's not necessary).
Have you guys thought about distributing sdk in a phar? It will be self-contained, no autoloader needed.
@SammyK it could be nice to update the description of that issue where each point would mention their corresponding PR (when there is one!) :)
Hi, This should be added in the roadmap
Thoughts? :)
get()
to accept array of params since it's the most requested featuredefault_graph_version
required and remove the fallback constantFacebook
prefix from nearly all classesfacebook-php-sdk-v4
tofacebook-php-sdk
and add 301; abandonfacebook/php-sdk-v4
on Packagist and create new alias:facebook/sdk
GraphNode
's andGraphEdge
's and just return a Guzzle response stream?Context
orEnvironment
namespace?