PHPackages                             jstewmc/gravity - 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. jstewmc/gravity

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

jstewmc/gravity
===============

A framework-agnostic service and configuration manager for PHP

v0.1.1(7y ago)4131[5 issues](https://github.com/jstewmc/gravity/issues)MITPHPPHP ^7.2

Since Feb 23Pushed 7y ago3 watchersCompare

[ Source](https://github.com/jstewmc/gravity)[ Packagist](https://packagist.org/packages/jstewmc/gravity)[ RSS](/packages/jstewmc-gravity/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (8)Versions (3)Used By (0)

Gravity
=======

[](#gravity)

Gravity lets other developers define settings and services in *your* dependency injection container using files in *their* packages. By pulling everything together, Gravity makes it easy to build and share small, configurable services.

[![Build Status](https://camo.githubusercontent.com/7b064a726c91c3a76eb6af37725cc0af184fd1a82692edc305ebe9659e45f45c/68747470733a2f2f7472617669732d63692e636f6d2f6a737465776d632f677261766974792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/jstewmc/gravity) [![codecov](https://camo.githubusercontent.com/3e3019c11453f29f64ced2b44ecd727f0dae78c8bf978b9c0490e874c7ef7813/68747470733a2f2f636f6465636f762e696f2f67682f6a737465776d632f677261766974792f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/jstewmc/gravity)

Usage
-----

[](#usage)

As a *package author*, you'll define services and settings in your repository using the `set()` method:

```
# /path/to/package/.gravity/foo.php

$g->set('foo.bar.baz', true);            // defines a setting
$g->set('Foo\Bar\Baz', new StdClass());  // defines a service
```

As a *package consumer*, you'll request services and settings in your project using the `get()` method:

```
# /path/to/project/file.php

$g = (new \Jstewmc\Gravity\Gravity())->pull();  // returns Gravity's manager

$g->get('foo.bar.baz');  // returns true
$g->get('Foo\Bar\Baz');  // returns the StdClass instance
```

Gravity works entirely within your local filesystem. When you call the `pull()` method, Gravity will find the current project's root directory; search it, as well as your `vendor` directory, for Gravity files; load each file's service and setting definitions into the manager; and, return the manager to you. That's it!

Documentation
-------------

[](#documentation)

Gravity's [documentation](https://github.com/jstewmc/gravity/blob/master/docs/index.md) is available online or in the `docs` directory.

We strive to maintain great documentation. If you see a mistake or have a suggestion, feel free to fork and fix it!

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

[](#installation)

Gravity requires [PHP 7.2+](https://secure.php.net).

Gravity is multi-platform, and we strive to make it run equally well on Windows, Linux, and OSX.

Gravity must be installed via [Composer](https://getcomposer.org). To do so, add the following line to the `require` section of your `composer.json` file (where `x` is the latest major version), and run `composer update`:

```
{
   "require": {
       "jstewmc/gravity": "^x"
   }
}
```

Examples
--------

[](#examples)

You can run most examples in the documentation by cloning the repository to your computer, navigating to it on your filesystem, and using the PHP command line.

```
# navigate to a directory on your computer
$ cd ~/projects

# clone the repository to your computer
~/projects $ git clone https://github.com/jstewmc/gravity.git

# navigate to the repository
~/projects $ cd gravity

# run the first example
~/projects/gravity $ php examples/first.php
```

Most examples use `assert()` statements, and will output nothing when successful, unless stated otherwise.

Compliance
----------

[](#compliance)

This library strives to adhere to the following standards:

1. [Keep a Changelog 1.0](http://keepachangelog.com/en/1.0.0/)
2. [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
3. [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md)
4. [PSR-16](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md)
5. [Semantic Versioning 2.0](http://semver.org/spec/v2.0.0.html)
6. [SODO Design Pattern 0.1.0](https://github.com/jstewmc/sodo-design-pattern)

If you spot an error, please let us know!

License
-------

[](#license)

This library is licensed under the [MIT license](LICENSE).

Credits
-------

[](#credits)

This library was originally developed by [Jack Clayton](mailto:clayjs0@gmail.com) with input from good friends like [Andy O'brien](https://github.com/javabudd) and [Harry Wallin](https://github.com/BillwoodMarbles).

We hope you enjoy it!

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.9% 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 ~1 days

Total

2

Last Release

2684d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/50fecae0a7fd2119681bc133e496e7166b01a59f850a3c909e100bd427c6b28b?d=identicon)[Jstewmc](/maintainers/Jstewmc)

---

Top Contributors

[![jstewmc](https://avatars.githubusercontent.com/u/1192893?v=4)](https://github.com/jstewmc "jstewmc (190 commits)")[![javabudd](https://avatars.githubusercontent.com/u/611826?v=4)](https://github.com/javabudd "javabudd (42 commits)")

---

Tags

phpSettingsmanagerservicesgravity

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jstewmc-gravity/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M19.7k](/packages/laravel-framework)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k39](/packages/civicrm-civicrm-core)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[illuminate/contracts

The Illuminate Contracts package.

706130.3M13.0k](/packages/illuminate-contracts)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k48](/packages/ecotone-ecotone)

PHPackages © 2026

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