PHPackages                             helsingborg-stad/acfservice - 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. helsingborg-stad/acfservice

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

helsingborg-stad/acfservice
===========================

Simplifies ACF integration by providing a centralized AcfService that exposes global ACF functions in a streamlined manner. Simplify your development workflow and enhance ACF integration with ease.

1.3.0(10mo ago)148.8k—2.2%12MITPHPPHP ^8.1CI passing

Since Apr 24Pushed 10mo ago3 watchersCompare

[ Source](https://github.com/helsingborg-stad/acfservice)[ Packagist](https://packagist.org/packages/helsingborg-stad/acfservice)[ RSS](/packages/helsingborg-stad-acfservice/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (23)Used By (12)

[![Contributors](https://camo.githubusercontent.com/b84d038677dbcedea7e98258f4b40de358c509ec843e7786abddac76f65d2389/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f68656c73696e67626f72672d737461642f61636673657276696365)](https://github.com/helsingborg-stad/acfservice/graphs/contributors)[![Forks](https://camo.githubusercontent.com/87c872ad02a723722cf7418381bdf94d370bfe4ee79a862fcaf8cdbfef85c5af/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f68656c73696e67626f72672d737461642f616366736572766963652e7376673f7374796c653d666c61742d737175617265)](https://github.com/helsingborg-stad/acfservice/network/members)[![Stargazers](https://camo.githubusercontent.com/f192da07a63915fd2db00a6da119348f8524473c29be033954a4cf286d94d2ac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f68656c73696e67626f72672d737461642f616366736572766963652e7376673f7374796c653d666c61742d737175617265)](https://github.com/helsingborg-stad/acfservice/stargazers)[![Issues](https://camo.githubusercontent.com/788327dba5e6d98c7c0b56517f5dd992ca040df8aa0381ac2e2cc7667ada8d73/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f68656c73696e67626f72672d737461642f616366736572766963652e7376673f7374796c653d666c61742d737175617265)](https://github.com/helsingborg-stad/acfservice/issues)[![License](https://camo.githubusercontent.com/48c95fde21d068f78d2e1f4f0de26f2c2275e375c42a297b72e4ef8d1138a8a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f68656c73696e67626f72672d737461642f616366736572766963652e7376673f7374796c653d666c61742d737175617265)](https://github.com/helsingborg-stad/acfservice/blob/main/LICENSE)

[![Unit Tests](https://github.com/helsingborg-stad/acfservice/actions/workflows/php-test.yml/badge.svg)](https://github.com/helsingborg-stad/acfservice/actions/workflows/php-test.yml/badge.svg)[![PHP Versions](https://camo.githubusercontent.com/021916a7f723c2917effa449997480e902c2a15fb538f353984ebf87e6f511d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d3737376262332e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535)](https://camo.githubusercontent.com/021916a7f723c2917effa449997480e902c2a15fb538f353984ebf87e6f511d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d3737376262332e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535)

AcfService
==========

[](#acfservice)

Simplifies ACF integration by providing a centralized AcfService that exposes global ACF functions in a streamlined manner. Simplify your development workflow and enhance ACF integration with ease.

[Report Bug](https://github.com/helsingborg-stad/acfservice/issues)· [Request Feature](https://github.com/helsingborg-stad/acfservice/issues)

About AcfService
----------------

[](#about-acfservice)

Enable the use of global ACF functions in plugins and themes where applying Interface Segregation. Different flavors of the ACF Service can be utilized by applying available decorators.

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

1. Install the package via composer:

```
composer require helsingborg-stad/acfservice
```

2. Use the AcfService in your plugin or theme:

```
use AcfService\Implementations\NativeAcfService;

$acfService = new NativeAcfService();
$fields = $acfService->getFields(123);
```

### Built With

[](#built-with)

- PHP

Tests
-----

[](#tests)

### Run tests

[](#run-tests)

Run `composer test` in the terminal.

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

[](#contributing)

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

Using AcfService in tests
-------------------------

[](#using-acfservice-in-tests)

To make it easier when testing code that depends on the AcfService or parts of it, a FakeAcfService implementation is available. This implementation is useful when you want to test your code without having to rely on the ACF functions.

### Example

[](#example)

Consider that you have the following class that utilizes a part of the AcfService:

```
use AcfService\Contracts\GetFields;

class MyService
{
    public function __construct(private GetFields $acfService)
    {
    }

    public function getFields(): int
    {
        return $this->acfService->getFields();
    }
}
```

You can then use FakeAcfService in your tests to fake the results of the AcfService as well as verifying the calls made to the AcfService functions:

```
use AcfService\Implementations\FakeAcfService;
use PHPUnit\Framework\TestCase;

class MyServiceTest extends TestCase
{
    public function testGetFields()
    {
        // Given
        $fakeAcfService = new FakeAcfService(['getFields' => ['fieldName' => 'fieldValue']]);
        $myService = new MyService($fakeAcfService);

        // When
        $fields = $myService->getFields();

        // Then
        $this->assertEquals([], $acfService->methodCalls['getFields'][0]);
        $this->assertEquals(['fieldName' => 'fieldValue'], $fields);
    }
}
```

### Passing return values to the FakeAcfService

[](#passing-return-values-to-the-fakeacfservice)

The FakeAcfService constructor accepts an array of key-value pairs where the key is the name of the method and the value is the return value of the method.

```
# Using a generic return value for all calls to the method.
$fakeAcfService = new FakeAcfService(['getFields' => ['field' => 'value']]);
$fakeAcfService->getFields(); // Returns ['field' => 'value']
$fakeAcfService->getFields(321); // Returns ['field' => 'value']
$fakeAcfService->getFields(123); // Returns ['field' => 'value']

# Using a callback to determine the return value based on the arguments passed to the method.
$return         = fn($postId) => $postId === 123 ? ['field' => 'value'] : [];
$fakeAcfService = new FakeAcfService(['getFields' => $return]);
$fakeAcfService->getFields(); // Returns false
$fakeAcfService->getFields(321); // Returns false
$fakeAcfService->getFields(123); // Returns ['field' => 'value']
```

License
-------

[](#license)

Distributed under the [MIT License](https://github.com/helsingborg-stad/acfservice/blob/main/LICENSE).

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance53

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.3% 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 ~25 days

Total

18

Last Release

322d ago

Major Versions

0.9.1 → 1.0.12025-04-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/f46fe64973c3e89d15c745c0bf601c25983bafea81d30e64d4bf813a6f8c8c7c?d=identicon)[sebastianthulin](/maintainers/sebastianthulin)

---

Top Contributors

[![thorbrink](https://avatars.githubusercontent.com/u/1064724?v=4)](https://github.com/thorbrink "thorbrink (14 commits)")[![NiclasNorin](https://avatars.githubusercontent.com/u/103985736?v=4)](https://github.com/NiclasNorin "NiclasNorin (5 commits)")[![sebastianthulin](https://avatars.githubusercontent.com/u/797129?v=4)](https://github.com/sebastianthulin "sebastianthulin (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/helsingborg-stad-acfservice/health.svg)

```
[![Health](https://phpackages.com/badges/helsingborg-stad-acfservice/health.svg)](https://phpackages.com/packages/helsingborg-stad-acfservice)
```

###  Alternatives

[mekras/botobor

PHP antispam library

2135.5k](/packages/mekras-botobor)[doctormckay/steam-totp

PHP library to deal with Steam's proprietary TOTP algorithm

2225.5k](/packages/doctormckay-steam-totp)

PHPackages © 2026

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