PHPackages                             oscarotero/server - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. oscarotero/server

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

oscarotero/server
=================

Simple class to emulate Apache's 'mod\_rewrite' functionality from the built-in PHP web server

v0.2.0(9y ago)5792MITPHPPHP &gt;=5.4

Since May 6Pushed 9y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

Server
======

[](#server)

Simple class to emulate Apache's "mod\_rewrite" functionality from the built-in PHP web server. This provides a convenient way to test any web application without having installed a "real" web server software here. It works with any cms or framework.

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

[](#installation)

This package is installable and autoloadable via Composer as [oscarotero/server](https://packagist.org/packages/oscarotero/server).

```
$ composer require oscarotero/server

```

Usage
-----

[](#usage)

Create a `server.php` file that will be our server script.

```
//The file exists and can be served as is
if (Server::run()) {
    return false;
}

//Otherwise, go with normal php operations
require __DIR__.'/index.php';
```

Launch the php server:

```
php -S localhost:8000 server.php
```

That's all, you could see the web in your browser in `http://localhost:8000`.

### Changing the public directory

[](#changing-the-public-directory)

By default, [getcwd](http://php.net/getcwd) is used to get the base directory of the server. But it can be changed using the first argument. Example:

```
//The file exists in public and can be served as is
if (Server::run(__DIR__.'/public')) {
    return false;
}

//Or include the index.php script
require_once __DIR__.'/public/index.php';
```

### Execute php files

[](#execute-php-files)

If the file has the php extension, the path is returned, so it can be included. This is only needed if the base directory is different that the current directory and the site does not have an unique php file (wordpress sites, for example).

```
if ($file = Server::run(__DIR__.'/wordpress')) {
    require $file;
}
```

API
---

[](#api)

As seen in the previous examples, the method `Server::run()` can return three values:

- `true` Means that the file exists and can be served directly by the php server
- `string` Means that the file exists but must be included (is a php file that cannot be server directly)
- `false` Means that the file does not exists

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

3335d ago

### Community

Maintainers

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

---

Top Contributors

[![oscarotero](https://avatars.githubusercontent.com/u/377873?v=4)](https://github.com/oscarotero "oscarotero (3 commits)")

---

Tags

serverrewrite

### Embed Badge

![Health badge](/badges/oscarotero-server/health.svg)

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

###  Alternatives

[spatie/laravel-webhook-server

Send webhooks in Laravel apps

1.1k9.7M25](/packages/spatie-laravel-webhook-server)[felixfbecker/language-server-protocol

PHP classes for the Language Server Protocol

22479.7M6](/packages/felixfbecker-language-server-protocol)[clue/socket-raw

Simple and lightweight OOP wrapper for PHP's low-level sockets extension (ext-sockets).

35211.7M50](/packages/clue-socket-raw)[voryx/thruway

Thruway WAMP router core

6761.0M17](/packages/voryx-thruway)[php-mcp/server

PHP SDK for building Model Context Protocol (MCP) servers - Create MCP tools, resources, and prompts

848482.3k46](/packages/php-mcp-server)[laminas/laminas-server

Create Reflection-based RPC servers

2424.4M27](/packages/laminas-laminas-server)

PHPackages © 2026

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