PHPackages                             oguz-yilmaz/parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. oguz-yilmaz/parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

oguz-yilmaz/parser
==================

Lets you create lists of url redirects from csv file for bot Apache and Nginx and custom.

02

Since Apr 5Compare

[ Source](https://github.com/oguz-yilmaz/Parser)[ Packagist](https://packagist.org/packages/oguz-yilmaz/parser)[ RSS](/packages/oguz-yilmaz-parser/feed)WikiDiscussions Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

301 Redirect Parser
===================

[](#301-redirect-parser)

- [Installation](#installation)
- [Usage](#usage)
- [Methods](#methods)
- [Example Csv](#example-csv)

This library lets you create lists of url redirects from csv file.

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

[](#installation)

Using composer
--------------

[](#using-composer)

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

```
composer require oguz-yilmaz/parser
```

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';

$file = new Parser\File('urls.csv');
$parser = new Parser\Parser($file, new Parser\ApacheStrategy());

$parser->setRedirectColumns([0,1])
       ->setMainUrl('https://www.example.com')
       ->parse();

echo $parser;
```

Example Output
--------------

[](#example-output)

[![Example OUTPUT](./img/example-output.PNG)](./img/example-output.PNG)

Methods
=======

[](#methods)

setRedirectColumns()
--------------------

[](#setredirectcolumns)

This is the columns in the csv files.It accepts array with length 2. First element of the array will represent the column of the urls that will be redirected to the urls in the column represented by the second element in the array.

setMainUrl()
------------

[](#setmainurl)

Sets the main url of the site so that you can get and use in execute() method of the strategy you are using.
Here is an example strategy that uses main url:

```
class ApacheStrategy implements StrategyInterface
{
    public function execute(string $pathFrom, string $pathTo, string $mainUrl = ''): string
    {
        return "Redirect 301 $pathFrom $mainUrl$pathTo";
    }
}
```

Definin your own custom Strategy class
--------------------------------------

[](#definin-your-own-custom-strategy-class)

You should implement the **Parser\\StrategyInterface** interface:

```
class CustomStrategy implements Parser\StrategyInterface
{
    public function execute(string $pathFrom, string $pathTo, string $mainUrl = ''): string
    {
        return 'Your redirect strategy for each of url';
    }

}

$file = new Parser\File('urls.csv');
$parser = new Parser\Parser($file, new CustomStrategy());

$parser->setRedirectColumns([1,3])
       ->setMainUrl('https://www.example.com')
       ->parse();

echo $parser;
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/afdcf3004e8743c223b158776ec8b80dd515c65d7397df64521a914162544ab9?d=identicon)[ogz.yilmaz](/maintainers/ogz.yilmaz)

---

Top Contributors

[![oguz-yilmaz](https://avatars.githubusercontent.com/u/35298601?v=4)](https://github.com/oguz-yilmaz "oguz-yilmaz (16 commits)")

### Embed Badge

![Health badge](/badges/oguz-yilmaz-parser/health.svg)

```
[![Health](https://phpackages.com/badges/oguz-yilmaz-parser/health.svg)](https://phpackages.com/packages/oguz-yilmaz-parser)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46143.1k6](/packages/jstewmc-rtf)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

112.9k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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