PHPackages                             ahoicloud/co2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ahoicloud/co2

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ahoicloud/co2
=============

Package for laravel calculating Co2 emission based on Sustainable Web Design (SWD) model

v1.0.2(3y ago)312[3 PRs](https://github.com/ahoicloud/co2/pulls)MITPHPPHP ^8.1

Since Feb 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ahoicloud/co2)[ Packagist](https://packagist.org/packages/ahoicloud/co2)[ Docs](https://github.com/ahoicloud/co2)[ RSS](/packages/ahoicloud-co2/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (12)Versions (6)Used By (0)

Package for Laravel calculating Co2 emission based on Sustainable Web Design (SWD) model
========================================================================================

[](#package-for-laravel-calculating-co2-emission-based-on-sustainable-web-design-swd-model)

[![Latest Version on Packagist](https://camo.githubusercontent.com/733c53a19575234c5d423b39dae8d3948e203cc3a086b7c261f761969da976ea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61686f69636c6f75642f636f322e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ahoicloud/co2)[![GitHub Tests Action Status](https://camo.githubusercontent.com/965ca21286e452b92d8c320775fdd04e5db58ff17cb3c63ad385f570707dcb5a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61686f69636c6f75642f636f322f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ahoicloud/co2/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ea2aacfd3931050722518f3cd3a6d4e04f0fd46a16bcca1712cf0f973fab65b6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61686f69636c6f75642f636f322f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/ahoicloud/co2/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/f54318e9dae1b3fa5e174ba2c7ae2bae446ed99c1bc16b00dbe121da3164b17d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61686f69636c6f75642f636f322e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ahoicloud/co2)

Every byte of data that’s uploaded or downloaded produces CO2. By being able to calculate these emissions, developers can enabled themself and their users to create more efficient, lower carbon decisions. Here are a few examples:

- Create a carbon budget for your site
- Inform the user when they uploading or downloading carbon intensive files

The package uses the [Sustainable Web Design (SWD)](https://sustainablewebdesign.org/calculating-digital-emissions) model. The yearly average grid intensity data comes from [Ember](https://ember-climate.org/data/data-explorer/), as well as marginal intensity data from the [UNFCCC](https://unfccc.int/) (United Nations Framework Convention on Climate Change).

The package is build for [Laravel](https://github.com/laravel/framework) and is based on the great work done by [The Green Web Foundation](https://thegreenwebfoundation.org) in the [CO2.js](https://github.com/thegreenwebfoundation/co2.js) package.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require ahoicloud/co2
```

### Optional

[](#optional)

You can publish the config file with:

```
php artisan vendor:publish --tag="co2-config"
```

This is the contents of the published config file:

```
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,

];
```

Usage
-----

[](#usage)

### Total energy use by each corresponding system component in kilowatt hours

[](#total-energy-use-by-each-corresponding-system-component-in-kilowatt-hours)

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

Or as a facade

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

### Total co2 figures key by the each component

[](#total-co2-figures-key-by-the-each-component)

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

Or as a facade

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

### Total co2 figures key by the each component

[](#total-co2-figures-key-by-the-each-component-1)

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

Or as a facade

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

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Arne Breitsprecher](https://github.com/ahoicloud)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

The code for [thegreenwebfoundation/co2.js](https://github.com/thegreenwebfoundation/co2.js) is licensed Apache 2.0. ([What does this mean?](https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)))

The average carbon intensity data from Ember is published under the Creative Commons ShareAlike Attribution Licence ([CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)). ([What does this mean?](https://tldrlegal.com/license/creative-commons-attribution-sharealike-4.0-international-(cc-by-sa-4.0)))

The marginal intensity data is published by the Green Web Foundation, under the Creative Commons ShareAlike Attribution Licence ([CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)). ([What does this mean?](https://tldrlegal.com/license/creative-commons-attribution-sharealike-4.0-international-(cc-by-sa-4.0)))

See LICENCE for more.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1236d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1068416?v=4)[Arne Breitsprecher](/maintainers/arnebr)[@arnebr](https://github.com/arnebr)

---

Top Contributors

[![arnebr](https://avatars.githubusercontent.com/u/1068416?v=4)](https://github.com/arnebr "arnebr (33 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")

---

Tags

climate-changeco2co2-emissionsgreenlaravellaravel-packagesustainabilitylaravelCO2ahoicloud

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ahoicloud-co2/health.svg)

```
[![Health](https://phpackages.com/badges/ahoicloud-co2/health.svg)](https://phpackages.com/packages/ahoicloud-co2)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k33.0M880](/packages/spatie-laravel-data)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

328482.0k25](/packages/codewithdennis-filament-select-tree)[nativephp/desktop

NativePHP for Desktop

38133.6k8](/packages/nativephp-desktop)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124581.3k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
