PHPackages                             webspanner/sourcemonkey - 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. webspanner/sourcemonkey

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

webspanner/sourcemonkey
=======================

1.1.3(7y ago)0791PHP

Since Jun 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/WebSpanner/sourcemonkey)[ Packagist](https://packagist.org/packages/webspanner/sourcemonkey)[ RSS](/packages/webspanner-sourcemonkey/feed)WikiDiscussions master Synced 4w ago

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

SourceMonkey
============

[](#sourcemonkey)

SourceMonkey is a package for working with source code, or text files on your local filesystem. SourceMonkey is useful for automated code generation and modification within your application.

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

[](#installation)

To install with composer use the following command:

```
composer install webspanner/sourcemonkey

```

Usage
-----

[](#usage)

### Instantiating the class

[](#instantiating-the-class)

Pass the fully qualified path to the file which you are editing into the constructor.

```
$sourceMonkey = new SourceMonkey('/tmp/my-file.php');

```

Methods
-------

[](#methods)

### `insertLineAfter()`

[](#insertlineafter)

To insert a string into a file after a given line number, moving all later text further down the page use the `insertLineAfter()` method

```
$sourceMonkey->insertLineAfter('some string', 42);

```

### `write()`

[](#write)

To write a string to a file, overwriting it's existing contents use the `write()` method.

```
$sourceMonkey->write('some string');

```

### `getLines()`

[](#getlines)

To read the contents of a file into a 1-indexed array of strings, without line breaks use the `getLines()` method.

```
$sourceMonkey->getLines();

```

### `getPath()`

[](#getpath)

Get the path of the SourceMonkey instance

```
$sourceMonkey->getPath();

```

### `firstLineWithString()`

[](#firstlinewithstring)

Returns the line number of the first line which contains the given string

```
$sourceMonkey->firstLineWithString($string);
{

```

### `deleteLine()`

[](#deleteline)

Delete the line at the given number

```
$sourceMonkey->deleteLine($lineNumber);

```

### `replaceLine()`

[](#replaceline)

Replace the contents of the given line number with the given string

```
$sourceMonkey->replaceLine($lineNumber, $string);

```

### `getProperty()`

[](#getproperty)

Get the PHP class property matching the given name from the class in the given source file and return it as a Property model object or null if it does not exist

```
$sourceMonkey->getProperty($propertyName);

```

### `getClass()`

[](#getclass)

Get the PHP class in the given file name

```
$sourceMonkey->getClass()

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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 ~83 days

Recently: every ~99 days

Total

6

Last Release

2891d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/03877158fbc08c0c35c727b54ce4299da8e70457a56ea44e1ff53ef43a3726c8?d=identicon)[webspanner](/maintainers/webspanner)

---

Top Contributors

[![AndrewFeeney](https://avatars.githubusercontent.com/u/13425337?v=4)](https://github.com/AndrewFeeney "AndrewFeeney (14 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/webspanner-sourcemonkey/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M268](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M997](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M363](/packages/illuminate-redis)[illuminate/process

The Illuminate Process package.

44869.2k98](/packages/illuminate-process)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)

PHPackages © 2026

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