PHPackages                             gggordon/php-sql-replacer - 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. [Database &amp; ORM](/categories/database)
4. /
5. gggordon/php-sql-replacer

ActiveLibrary[Database &amp; ORM](/categories/database)

gggordon/php-sql-replacer
=========================

Replace values in `SQL` files especially with serialized php values. Useful for database migrations/clones.

2.0.0(5y ago)04MITPHP

Since Oct 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/gggordon/php-sql-replacer)[ Packagist](https://packagist.org/packages/gggordon/php-sql-replacer)[ RSS](/packages/gggordon-php-sql-replacer/feed)WikiDiscussions main Synced 1mo ago

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

[![Build Status](https://camo.githubusercontent.com/1b5063dc673aad3779765f1e76b0ce49f5a704ec3eebea23c594998f763363f9/68747470733a2f2f7472617669732d63692e6f72672f6767676f72646f6e2f7068702d73716c2d7265706c616365722e7376673f6272616e63683d6d61696e)](https://travis-ci.org/gggordon/php-sql-replacer)[![Scrutinizer](https://camo.githubusercontent.com/f1356d68c9d1543610120ca6627bb8cf17d11bfe0ab96cf9cd3b99188a63951d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6767676f72646f6e2f7068702d73716c2d7265706c616365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/gggordon/php-sql-replacer/)[![Codecov](https://camo.githubusercontent.com/cbc47fbe2c6f2bf5b2a0a90230bb5af7bf1d82fe1b55b58fc629da2ebaa24c0f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6767676f72646f6e2f7068702d73716c2d7265706c616365722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/gggordon/php-sql-replacer)[![License](https://camo.githubusercontent.com/6778514dd5d08cc1e81633646883347efbc94f84374a7bf5facf11a3002250e4/68747470733a2f2f706f7365722e707567782e6f72672f6767676f72646f6e2f7068702d73716c2d7265706c616365722f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/gggordon/php-sql-replacer)[![Latest Stable Version](https://camo.githubusercontent.com/ed387a140b1b8d5248634746e897be761454fa2627337e0ef819e62d92b10bcf/68747470733a2f2f706f7365722e707567782e6f72672f6767676f72646f6e2f7068702d73716c2d7265706c616365722f76657273696f6e3f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/gggordon/php-sql-replacer)[![Latest Unstable Version](https://camo.githubusercontent.com/fd3821cf11e2794243bf923e1d24f4c6d215d4732b089bcc00794e6592104fbf/68747470733a2f2f706f7365722e707567782e6f72672f6767676f72646f6e2f7068702d73716c2d7265706c616365722f762f756e737461626c653f666f726d61743d666c61742d737175617265)](//packagist.org/packages/gggordon/php-sql-replacer)

PHP SQL Replacer
================

[](#php-sql-replacer)

A utility to replace strings/values in `SQL` files especially with **serialized** `php` values. Useful for database migrations/clones.

Installation
============

[](#installation)

```
composer require gggordon/php-sql-replacer

```

Usage
=====

[](#usage)

Command Line Usage
------------------

[](#command-line-usage)

```
./bin/php-sql-replacer --input-file-path="./original.sql" --output-file-path="./updated.sql" --match="Original Text" --replace="New Text"

Required Options:
--input-file-path   : Path of input file
--output-file-path  : Path of output file
--match             : Exact string to look for
--replace           : String to replace match with

```

Using Code
----------

[](#using-code)

If you already have the contents stored as a string, you may follow the example below to replace the contents.

```
