Installed Composer successfully and now have a vendor directory in the project's root directory in which braintree/braintree_php/ lives. Went through the article mentioned above down to where it talks about autoloading. I wasn't able to get either of the examples to work directly from inside a Fuel controller.
I added the include_once for the vendor autoload line to the bootstrap index.php file so it looks like this at the bottom of that file... include_once './vendor/autoload.php';
require_once BASEPATH.'core/CodeIgniter.php';
I know I can't just load->library because that's gonna look in the fuel/application/libraries directory. I'm wanting to establish the braintree class obj in a store controller and pass the vars from the class to the views as well as load the class in a store_model for processing stuff in my local database.
Can't seem to find anything peculiar to Fuel on this and would really appreciate it if you'd divulge your methods for using Composer with Fuel.
I am able to call all the functions using the long verbose namespaces but would love to find a way to shorten this. I'm dealing with an auto-loaded abstract class. For example, the Braintree classes directory is inside braintree_php/lib/ and has a subclass file named Version.php and that contains the method get(). This works just fine directly in a view file even: $braintree_version = Braintree_Version::get();
var_dump($braintree_version);But, man, it would be great if I could reference these by shorter variable name because, for example, there's a Configuration Class with 4 methods that need to be called initially and this kind of thing gets old... Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('<id here>');
Braintree_Configuration::publicKey('<public key here');
Braintree_Configuration::privateKey('<private key here>'); Any help would be greatly appreciated.
I think you'll need to use the long class names unless you perhaps map them to some sort of alias array. If they were using more PHP 5.3 methods they could use name spacing.
Comments
Trying to use the Braintree Payments library
https://www.braintreepayments.com/docs/php
I'm on a Mac and used this article to get going with Composer...
http://code.tutsplus.com/tutorials/easy-package-management-with-composer--net-25530
Installed Composer successfully and now have a vendor directory in the project's root directory in which braintree/braintree_php/ lives. Went through the article mentioned above down to where it talks about autoloading. I wasn't able to get either of the examples to work directly from inside a Fuel controller.
I added the include_once for the vendor autoload line to the bootstrap index.php file so it looks like this at the bottom of that file...
include_once './vendor/autoload.php'; require_once BASEPATH.'core/CodeIgniter.php';
I know I can't just load->library because that's gonna look in the fuel/application/libraries directory. I'm wanting to establish the braintree class obj in a store controller and pass the vars from the class to the views as well as load the class in a store_model for processing stuff in my local database.Can't seem to find anything peculiar to Fuel on this and would really appreciate it if you'd divulge your methods for using Composer with Fuel.
I am able to call all the functions using the long verbose namespaces but would love to find a way to shorten this. I'm dealing with an auto-loaded abstract class. For example, the Braintree classes directory is inside braintree_php/lib/ and has a subclass file named Version.php and that contains the method get(). This works just fine directly in a view file even:
$braintree_version = Braintree_Version::get(); var_dump($braintree_version);
But, man, it would be great if I could reference these by shorter variable name because, for example, there's a Configuration Class with 4 methods that need to be called initially and this kind of thing gets old...Braintree_Configuration::environment('sandbox'); Braintree_Configuration::merchantId('<id here>'); Braintree_Configuration::publicKey('<public key here'); Braintree_Configuration::privateKey('<private key here>');
Any help would be greatly appreciated.
Thanks!