PHPackages                             ffi/work-directory - 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. ffi/work-directory

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

ffi/work-directory
==================

PHP library for interact with working directory

1.0.0(2y ago)14.2k15MITPHPPHP ^7.4|^8.0

Since Aug 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/php-ffi/work-directory)[ Packagist](https://packagist.org/packages/ffi/work-directory)[ RSS](/packages/ffi-work-directory/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (5)

Work Directory
==============

[](#work-directory)

 [![PHP 8.1+](https://camo.githubusercontent.com/42a8ad41e9a1092284ea53982fa478cc1eef4d413f8c6d84f3c2d80608d4bbf7/68747470733a2f2f706f7365722e707567782e6f72672f6666692f776f726b2d6469726563746f72792f726571756972652f7068703f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ffi/work-directory) [![Latest Stable Version](https://camo.githubusercontent.com/57df2644cae98d8d2d49cd13eb6a1e4ae60517f933b86dd35d6e7589033f5859/68747470733a2f2f706f7365722e707567782e6f72672f6666692f776f726b2d6469726563746f72792f76657273696f6e3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ffi/work-directory) [![Latest Unstable Version](https://camo.githubusercontent.com/9733fbf00e6918eda91454c8c22a971b3e19e560e0752d290bf3893fc7c13bc0/68747470733a2f2f706f7365722e707567782e6f72672f6666692f776f726b2d6469726563746f72792f762f756e737461626c653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ffi/work-directory) [![Total Downloads](https://camo.githubusercontent.com/dcbeef27f3cc7d599a29476367fb8d57a7d56bbd2b7050ca0614a7a7beb26794/68747470733a2f2f706f7365722e707567782e6f72672f6666692f776f726b2d6469726563746f72792f646f776e6c6f6164733f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ffi/work-directory) [![License MIT](https://camo.githubusercontent.com/8b3ac17e94a32a2088b5d519f732ac4087275d1e8a94d694d8b01ab75377059e/68747470733a2f2f706f7365722e707567782e6f72672f6666692f776f726b2d6469726563746f72792f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://raw.githubusercontent.com/php-ffi/work-directory/master/LICENSE.md)

 [![](https://github.com/php-ffi/work-directory/workflows/build/badge.svg)](https://github.com/php-ffi/work-directory/actions)

In the case that during the loading of a binary (like `*.so`, `*.dylib` or `*.dll`) through FFI it depends on some other binary module, then errors may occur if the first one and dependent libraries are in different directories, like:

```
// - bin/
//   - main.dll
//   - other/
//     - dependency.dll

$ffi = \FFI::cdef('...', __DIR__ . '/bin/main.dll');
// Error like "can not load ..."
// - In this case, an error occurs because the specified
//   dependency ("dependency.dll") could not be found in "bin"
//   or working directory.
```

This library allows you to load similar dependencies:

```
// Use "bin/other" directory for dependencies.
\FFI\WorkDirectory\WorkDirectory::set(__DIR__ . '/bin/other');

//
$ffi = \FFI::cdef('...', __DIR__ . '/bin/main.dll');
```

You can also use the built-in [chdir function](https://www.php.net/manual/en/function.chdir.php)for such operations, however it will only work in case of a Non-Thread Safe PHP build ([see remark](https://www.php.net/manual/en/function.chdir.php#refsect1-function.chdir-notes)).

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4

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

[](#installation)

Library is available as composer repository and can be installed using the following command in a root of your project.

```
$ composer require ffi/work-directory
```

Usage
-----

[](#usage)

### Get Current Work Directory

[](#get-current-work-directory)

```
$directory = \FFI\WorkDirectory\WorkDirectory::get();

if ($directory !== null) {
    echo 'CWD is: ' . $directory;
}
```

### Update Current Work Directory

[](#update-current-work-directory)

Getting the full path to the library.

```
$directory = __DIR__ . '/path/to/directory';

if (\FFI\WorkDirectory\WorkDirectory::set($directory)) {
    echo 'CWD has been updated to: ' . $directory;
}
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1059d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150420?v=4)[Ruslan Sharipov](/maintainers/Serafim)[@serafim](https://github.com/serafim)

---

Tags

utilitylocationbinfficwdchdirgetcwd

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ffi-work-directory/health.svg)

```
[![Health](https://phpackages.com/badges/ffi-work-directory/health.svg)](https://phpackages.com/packages/ffi-work-directory)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k430.4M1.7k](/packages/nette-utils)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.3M192](/packages/danielstjules-stringy)[torann/geoip

Support for multiple Geographical Location services.

2.2k15.3M98](/packages/torann-geoip)[stevebauman/location

Retrieve a user's location by their IP Address

1.3k8.5M89](/packages/stevebauman-location)[spatie/geocoder

Geocoding addresses to coordinates

8555.2M20](/packages/spatie-geocoder)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4915.7M18](/packages/voku-arrayy)

PHPackages © 2026

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