CakePHP Constants Definition

I want to include the Google API in my application. I want to define the Outh2 key, the secret key and the developer keys as constants that I can call and use in the application controller.

Which place is best identified?

+6
source share
2 answers

/app/Config/bootstrap.php

I would not set them as constants, I would use the configure class to store them:

Configure::write(array( 'outh2.key'=>'foo', 'outh2.secret_key'=>'bar', 'outh2.dev_key'=>'baz' )); $key = Configure::read('outh2.key'); 
+9
source

You can declare a class that works with Google APIs in providers, there you define needle constants, as usual. And in your application controller, enable only the provider:

 <?php App::import('Vendor', 'google', array('file' => 'google.php')); class AppController extends Controller { ... 
+1
source

Source: https://habr.com/ru/post/917453/


All Articles