Debug Php calls sent from my iOS app (AFNetworking 2.0)
I'm actually working on an iOS app which calls a local php server.
I use AppCode as my iOS IDE and PhpStorm for .. Php :D
I wanted to debug my webservices call directly from PhpStorm. Usually it's easy with PhpStorm bookmarklets but here, no bookmarklet in AFNetworking.
So I decided to add a new Cookie in my NSHttpCookieStorage. (edit NSHTTPCookieDomain and NSHTTPCookiePath depending on your domain/website)
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *properties = @{
NSHTTPCookieName : @"XDEBUG_SESSION",
NSHTTPCookieValue : @"PHPSTORM",
NSHTTPCookieDomain : @"server.local",
NSHTTPCookiePath : @"/"
};
NSHTTPCookie *newCookie = [[NSHTTPCookie alloc] initWithProperties:properties];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:newCookie];
[manager GET:@"http://server.local/index.php" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Response: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
Now, my http calls get caught by PhpStorm debugger !
Edit : You can also add this to your php.ini
xdebug.remote_autostart = 1
Written by Karl COSSE
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#