PHP code example of ahoicloud / co2

1. Go to this page and download the library: Download ahoicloud/co2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ahoicloud / co2 example snippets


return [

    'KWH_PER_GB' => 0.81,
    'END_USER_DEVICE_ENERGY' => 0.52,
    'NETWORK_ENERGY' => 0.14,
    'DATACENTER_ENERGY' => 0.15,
    'PRODUCTION_ENERGY' => 0.19,
    'GLOBAL_GRID_INTENSITY' => 442,
    'RENEWABLES_GRID_INTENSITY' => 50,
    'FIRST_TIME_VIEWING_PERCENTAGE' => 0.75,
    'RETURNING_VISITOR_PERCENTAGE' => 0.25,
    'PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD' => 0.02,

];

$co2 = new Ahoicloud\Co2();
echo $co2->energyPerByteByComponent($byte);

use Ahoicloud\Co2\Facades\Co2;
echo Co2::energyPerByteByComponent($byte);

$co2 = new Ahoicloud\Co2();
echo $co2->co2byComponent($byte);

use Ahoicloud\Co2\Facades\Co2;
echo Co2::co2byComponent($byte);

$co2 = new Ahoicloud\Co2();
echo $co2->perByte($byte);

use Ahoicloud\Co2\Facades\Co2;
echo Co2::perByte($byte);
bash
php artisan vendor:publish --tag="co2-config"