PHPackages                             nilportugues/php\_backslasher - 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. nilportugues/php\_backslasher

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

nilportugues/php\_backslasher
=============================

Adds all PHP internal functions to its namespace by adding backslash to them. Improves the application's performance when OPCache is on.

1.1.4(6y ago)889.3k518MITPHPPHP &gt;=5.4CI failing

Since Nov 1Pushed 6y ago6 watchersCompare

[ Source](https://github.com/nilportugues/php_backslasher)[ Packagist](https://packagist.org/packages/nilportugues/php_backslasher)[ Docs](http://nilportugues.com)[ RSS](/packages/nilportugues-php-backslasher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (18)

[![Build Status](https://camo.githubusercontent.com/04d236f18ca6bf831c68a1a6eae99aa7b49e96ec8382948f0ea77eb2782478d9/68747470733a2f2f7472617669732d63692e6f72672f6e696c706f727475677565732f7068702d6261636b736c61736865722e737667)](https://travis-ci.org/nilportugues/php-backslasher)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/23d4e4949c5a0661f39eb77e12d0af1088599037d43e8b0b50f73e97b24409fa/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e696c706f727475677565732f7068705f6261636b736c61736865722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nilportugues/php_backslasher/?branch=master) [![SensioLabsInsight](https://camo.githubusercontent.com/aed310f66a3a090a5a3543a7eed922affc7ceff083847d2b012d43bea8d90184/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38303961356261302d653761302d346430352d383533332d6539346661306264386239612f6d696e692e706e67)](https://insight.sensiolabs.com/projects/809a5ba0-e7a0-4d05-8533-e94fa0bd8b9a) [![Latest Stable Version](https://camo.githubusercontent.com/e0c1982777b4f9b9887d84fc92419bc50ea57197aa0d61308cef18778c9a422a/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f7068705f6261636b736c61736865722f762f737461626c65)](https://packagist.org/packages/nilportugues/php_backslasher) [![Total Downloads](https://camo.githubusercontent.com/d235eadea72cd8a636cce8445a67db0f3483e3ecd6f9fdcd2615ae7c10391322/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f7068705f6261636b736c61736865722f646f776e6c6f616473)](https://packagist.org/packages/nilportugues/php_backslasher) [![License](https://camo.githubusercontent.com/be0502353be221a92a7efd45fd5643363e04816130ca21028457c9298c25f9fe/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f7068705f6261636b736c61736865722f6c6963656e7365)](https://packagist.org/packages/nilportugues/php_backslasher)[![Donate](https://camo.githubusercontent.com/7b6de155df30b37b25eb5fec52f9213680c3dbf067dfb7d7e2850ac4096c7d05/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e6174655f534d2e676966)](https://paypal.me/nilportugues)

PHP BackSlasher
===============

[](#php-backslasher)

Tool to add all PHP **internal functions and constants** to its namespace by adding backslash to them.

Function resolution without the backslash forces the PHP internals to verify for each function call if function or constant belongs to current namespace or the global namespace. With the backslash PHP does not check the current namespace and therefore execution is faster when using OP Cache.

**Idea from Nikita Popov talk**:

- [PHP 7 – What changed internally? (PHP Barcelona 2015)](http://www.slideshare.net/nikita_ppv/php-7-what-changed-internally-php-barcelona-2015) (slide [72](http://image.slidesharecdn.com/php7internals-151101105627-lva1-app6891/95/php-7-what-changed-internally-php-barcelona-2015-72-638.jpg?cb=1446375542))

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

[](#installation)

Use [Composer](https://getcomposer.org) to install the package:

```
$ composer require --dev nilportugues/php_backslasher

```

Usage
-----

[](#usage)

```
$ php bin/php_backslasher fix

```

### Output

[](#output)

Works for functions in conditional statements, negative conditionals, placed in an array as key or value and any other normal use. Also adds a backslash to defined constants and true, false and null values.

#### Internal functions and constants

[](#internal-functions-and-constants)

```
echo strlen('Hello World');
var_dump(null);
var_dump(false);
echo DIRECTORY_SEPARATOR;
return true;

// becomes:
echo \strlen('Hello World');
\var_dump(\null);
\var_dump(\false);
echo \DIRECTORY_SEPARATOR;
return \true;
```

Contribute
----------

[](#contribute)

Contributions to the package are always welcome!

- Report any bugs or issues you find on the [issue tracker](https://github.com/nilportugues/php_backslasher/issues/new).
- You can grab the source code at the package's [Git repository](https://github.com/nilportugues/php_backslasher).

Support
-------

[](#support)

Get in touch with me using one of the following means:

- Emailing me at
- Opening an [Issue](https://github.com/nilportugues/php_backslasher/issues/new)

Authors
-------

[](#authors)

- [Nil Portugués Calderó](http://nilportugues.com)
- [The Community Contributors](https://github.com/nilportugues/php_backslasher/graphs/contributors)

License
-------

[](#license)

The code base is licensed under the [MIT license](LICENSE).

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community27

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 89.5% 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 ~148 days

Recently: every ~406 days

Total

12

Last Release

2218d ago

Major Versions

0.2.2 → 1.0.02015-11-04

PHP version history (2 changes)0.1.0PHP &gt;=5.4.0

0.2.0PHP &gt;=5.4

### Community

Maintainers

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

---

Top Contributors

[![nilportugues](https://avatars.githubusercontent.com/u/550948?v=4)](https://github.com/nilportugues "nilportugues (51 commits)")[![Desure85](https://avatars.githubusercontent.com/u/10466638?v=4)](https://github.com/Desure85 "Desure85 (3 commits)")[![flavioheleno](https://avatars.githubusercontent.com/u/471860?v=4)](https://github.com/flavioheleno "flavioheleno (2 commits)")[![k00ni](https://avatars.githubusercontent.com/u/381727?v=4)](https://github.com/k00ni "k00ni (1 commits)")

---

Tags

backslashcigitgit-hookgit-hooksnamespacephpphp-backslasherphp-internalsphp7phpfixerperformancefunctionoptimizationgitnamespaceHOOKnamespacesOpcachebackflashnikitamicro-optimization

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/nilportugues-php-backslasher/health.svg)

```
[![Health](https://phpackages.com/badges/nilportugues-php-backslasher/health.svg)](https://phpackages.com/packages/nilportugues-php-backslasher)
```

###  Alternatives

[ramsey/conventional-commits

A PHP library for creating and validating commit messages according to the Conventional Commits specification. Includes a CaptainHook action!

1931.2M122](/packages/ramsey-conventional-commits)[nilportugues/php_todo

Looks into the code using a user-defined list of to-do phrases and stops commit if the total amount increased or is above a threshold.

1210.0k](/packages/nilportugues-php-todo)[marcocesarato/php-conventional-changelog

Generate changelogs and release notes from a project's commit messages and metadata and automate versioning with semver.org and conventionalcommits.org

2511.3M109](/packages/marcocesarato-php-conventional-changelog)[amphibee/laravel-pint-pre-commit

Laravel Pint pre-commit hook allow you to analyse your code with the awesome Laravel Pint.

1943.9k](/packages/amphibee-laravel-pint-pre-commit)[wcm/git-php-hooks-library

A collection of Git PHP Hooks

1210.1k3](/packages/wcm-git-php-hooks-library)

PHPackages © 2026

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