i wan't to integrate Rollbar to my cakephp project but i dont know where to include the code referencing to rolbar in my app ?
i have use this code
<?php
use \Rollbar\Rollbar;
// Installs global error and exception handlers
$config = array(
// required
'access_token' => 'MY_ACCESS_TOKEN',
// optional - environment name
'environment' => 'production',
);
Rollbar::init($config);
But it works only for the page that i have added to, so please help how can i configure rollbar for cakephp application.
I should put this code in bootstrap.php
use \Rollbar\Rollbar;
// Installs global error and exception handlers
$config = array(
// required
'access_token' => 'ACCESS_TOKEN',
// optional - environment name
'environment' => 'production',
// optional - path to directory your code is in. Used for linking stack traces.
'root' => '/Users/brian/www/myapp'
);
Rollbar::init($config);
Related
I am using Luis Dias' Report Manager Plugin to generate some quick reports for an application I am developing. From my application dashboard I enter the plugin using the following:
<td style="text-align:center">
<button style="height:75px; width:175px; background-color:BurlyWood; font-size:20px; font-family:Verdana"
onclick="window.location.href='<?php echo Router::url(array('controller'=>'report_manager'
,'action'=>'reports'))?>'">Report Management</button>
I'd really like to open the Report Generator Wizard in a new window but that's a different issue..
Once I am done with the report generator I'd like to return to my dashboard in my application. However, I am now in the Plugin's domain and can't figure out a command to "route" me back to the calling application.
Thanks in advance
Mike
To 'escape' from a plugin when routing you need to pass plugin => false in the route array. For example:-
$this->Html->url([
'controller' => 'pages',
'action' => 'view',
1,
'plugin' => false
]);
If you don't pass the plugin attribute it assumes you want to remain in the context of the current plugin. You need to be careful with this wherever you use links where plugins are in use.
I am using CakePHP and was trying to implement https://github.com/josegonzalez/cakephp-environments
Which seemed to be going fine except that I have no idea where to specify the env specific database info.
Does anyone know where to set these?
I personally haven't used the plugin, however from looking at the code and the docs, if you were using the suggested database configuration, then it seems that you would define the options as either environment variables, which can be done in various ways, for example
in your server configuration (Apache example)
in your cloud varibale settings (Heroku example)
manually using putenv(), $_ENV, $_SERVER
$name = 'MYSQL_DB_HOST';
$value = 'localhost';
putenv("$name=$value");
$_ENV[$name] = $value;
$_SERVER[$name] = $value;
...
or as CakePHP configuration values via the Environment::configure() calls, something like:
Environment::configure('development',
true,
array(
'MYSQL_DB_HOST' => 'localhost',
'MYSQL_USERNAME' => 'user',
// ...
),
// ...
);
When trying to run CakePHP based application I'm getting following error:
2014-01-25 11:46:21 Error: [MissingHelperException] Helper class sessionHelper could not be found.
Exception Attributes: array (
'class' => 'sessionHelper',
'plugin' => false,
)
It occurred when I copied CakePHP application to production server. I never had error like this in any of previous developed CakePHP applications.
Just to mention that Session helper is loaded in AppController. PHP version on server is 5.3.10.
Try to include SessionHelper instead of sessionHelper
public $helpers = array('Session');
If the production server is on unix, this is important.
Include SessionHelper as cornelb said. And be careful when calling Session helper manually, just call it with capital 'S':
$this->Session->read('Auth.User');
I have a site running in localhost as a development environment and in a server for production.
There are some differences in some configuration files between both and I every time I have to update the changes in the server I have to be careful not to overwrite some files which are different.
I would like to be able to simplify this process by creating just one single file with the correct configuration for each environment.
I need to read that file currently in this Config files:
app/Config/email.php
app/Config/routes.php
And ideally, if possible in:
app/Vendor/Vendor_name/vendor_file.php
Is it possible somehow?
I have tried to use Configure::read and Configure::write but it seems it can not be done inside email settings such as public $smtp or in the routes file.
Thaks.
The routes file is simply a php file with calls to the router. You could very simply split it up into multiple files and load them yourself:
app/Config/
routes.php
routes_dev.php
routes_production.php
routes.php would then load the proper routes file.
<?php
if ($env == 'dev') {
include 'routes_dev.php';
} else {
include 'routes_production.php';
}
The email config is also just a php file. You could write a function to set the proper default config based on the environment.
class EmailConfig {
public function __construct() {
if ($env == 'dev') {
$this->default = $this->dev;
}
}
public $default = array(
'host' => 'mail.example.com',
'transport' => 'Smtp'
);
public $dev = array(
'host' => 'mail2.example.com',
'transport' => 'Smtp'
);
}
As for vendor files, that's a case by case basis.
If you have a deployment system, it might be better to actually have separate files for each environment (maybe even a full config directory) and rename them after the deployment build is complete, making Cake and your code none the wiser.
The way I used to handle this situation was to add environment variables to the apache virtualhost configuration.
SetEnv cake_apps_path /var/www/apps/
SetEnv cake_libs_path /var/www/libs/
This allowed me to then pull $_SERVER['cake_apps_path'] and $_SERVER['cake_libs_path']. Then each developer can set his own variables in his own virtualhost config, and you add that to the server's virtualhost config, and you're done. Each developer can have their own pathing.
I'm trying to execute some business logic after the checkout process in Drupal 7 with Drupal commerce module. I've read on the documentation that I can use the hook hook_commerce_checkout_complete but it's not called
function api_manager_commerce_checkout_complete($order) {
$ow = entity_metadata_wrapper('commerce_order', $order);
foreach ($ow->commerce_line_items as $line_item) {
$sku = $line_item->commerce_product->sku->value();
$record = array(
'uid' => get_user_id(),
'sku' => $sku,
'token' => uniqid(),
);
drupal_write_record('api_manager_product_user', $record);
}
}
For your information, I've disabled 'payment' and 'billing information' in the checkout configuration
Whenever a new hook is implemented in Drupal you are required to clear your cache ( class ). Only then would that particular hook be available and fired when invoked.
If you are using devel module, you can check out if your hook is recognized by the system by Drupal by using module_implements function. Devel module gives you a convenient tool at http://www.mysite.com/devel/php to try out such snippets.
dpm(module_implements('commerce_checkout_complete'));
If your module's name is not listed as the output of the above function then it means your hook is not recognized. As mentioned earlier please clear your cache in such case.