PHPackages                             samkitano/seo-gen - 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. samkitano/seo-gen

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

samkitano/seo-gen
=================

Generate sitemap.xml and robots.txt files in Laravel 4.2 with support for multi-language. Based on Hettiger/SeoAggregator

112PHP

Since Jun 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/samkitano/seo-gen)[ Packagist](https://packagist.org/packages/samkitano/seo-gen)[ RSS](/packages/samkitano-seo-gen/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SEO Aggregator
--------------

[](#seo-aggregator)

Generate robots.txt and multi-language sitemap.xml files in Laravel 4.2.

Based on [Hettiger/seo-aggregator](https://github.com/hettiger/seo-aggregator)

### Installation

[](#installation)

Require with composer

```
// composer.json

"require": {
    "php": ">=5.4.0",
    "samkitano/seo-gen": "dev-master",
    // ...
},
```

Add provider in `app\config\app.php`

```
// ...
'Samkitano\SeoGen\SeoGenServiceProvider',
```

Publish configuration file

```
php artisan config:publish samkitano/seo-gen
```

Modify `app\config\packages\samkitano\seo-gen\config.php` to suit your needs.

Provide the name of the file you are using to translate your routes in `'translated_routes_file'`. Do not include extension.

If you don't need to translate your url prefix (you wouldn't be here in that case now, would you?) you should probably use another package, but feel free to open a pull request and make some changes :)

For example purposes we will use the default `'translated_routes_file' => 'routes',`

### Usage examples with Laravel 4.2

[](#usage-examples-with-laravel-42)

Obviously, you will need to have your translation files ready:

```
/**
* app\lang\en\routes.php
*/

return array(
	'home'      => 'home',
	'portfolio' => 'portfolio',
	'contacts'  => 'contacts',
	'pages'     => 'pages',
	// ...
);
```

```
/**
* app\lang\pt\routes.php
*/

return array(
	'home'      => 'inicio',
	'portfolio' => 'portefolio',
	'contacts'  => 'contactos',
	'pages'     => 'paginas',
	// ...
);
```

```
/**
* app\lang\fr\routes.php
*/

return array(
	'home'      => 'accueil',
	'portfolio' => 'portefeuille',
	'contacts'  => 'contacts',
	'pages'     => 'pages',
	// ...
);
```

```
/**
* app\lang\de\routes.php
*/

return array(
	'home'      => 'startseite',
	'portfolio' => 'portefeuille',
	'contacts'  => 'kontakte',
	'pages'     => 'seiten',
	// ...
);
```

SeoGen will take a look at your app configuration file to find out your app's default language and the available languages.

```
/**
* app\config\app.php
*/

	/*
	|--------------------------------------------------------------------------
	| Application Locale Configuration
	|--------------------------------------------------------------------------
	|
	| The application locale determines the default locale that will be used
	| by the translation service provider. You are free to set this value
	| to any of the locales which will be supported by the application.
	|
	*/

	'locale' => 'en',

	/*
	|--------------------------------------------------------------------------
	| Available Languages
	|--------------------------------------------------------------------------
	|
	| Supported Languages
	|
	*/

	'languages' => array('en', 'pt', 'fr', 'de'),
```

Now you can use SeoGen wherever you like in your app.

For the sake of this example's simplicity we will do it right in `app\routes.php`, but you should use a controller instead.

```
/**
* app/routes.php
*/

use Samkitano\SeoGen\Facades\Sitemap;
use Samkitano\SeoGen\Facades\Robots;

// Language Selection
$languages  = array('en', 'pt', 'fr', 'de');
$locale     = Request::segment(1);

if ( in_array($locale, $languages) )
{
	\App::setLocale($locale);
	Session::put('locale', $locale);
}
else
{
	$locale = null;
}

Route::group( array('prefix' => $locale),
	function()
	{
		Route::get( trans('routes.home'),
			array('as' => 'home', 'uses' => 'ExampleController@home')
		);

		Route::get( trans('routes.portfolio'),
			array('as' => 'portfolio', 'uses' => 'ExampleController@portfolio')
		);

		Route::get( trans('routes.contacts'),
			array('as' => 'contacts', 'uses' => 'ExampleController@contacts')
		);

		Route::get( trans('routes.pages' . '/{slug}'),
			array('as' => 'pages', 'uses' => 'ExampleController@pages')
		);
	}
);

Route::get('sitemap.xml', function()
{
	$date_time = new DateTime('now');

	Sitemap::addLink($date_time, 'home');
	Sitemap::addLink($date_time, 'portfolio');
	Sitemap::addLink($date_time, 'contacts');

	$collection = Pages::all();
	Sitemap::addCollection($collection, 'pages');

	return Response::make( Sitemap::getSitemapXml() )
	               ->header('Content-Type', 'text/xml');
});

Route::get('robots.txt', function()
{
	Robots::disallowPath('/admin');
    return Response::make( Robots::getRobotsDirectives(true) )
    			   ->header('Content-Type', 'text/plain');
});
```

The above example should return a sitemap with something like

```

		http://example.com/en/home

		2015-06-16

		http://example.com/en/portfolio

		2015-06-16

		http://example.com/en/contacts

		2015-06-16

		http://example.com/en/pages/page-1

		2015-06-10

		http://example.com/en/pages/page-2

		2015-06-10

		http://example.com/en/pages/page-3

		2015-06-10

```

and robots.txt

```
User-agent: *
Disallow: /admin

Sitemap: http://example.com/sitemap.xml
```

### Notes

[](#notes)

SeoGen does NOT translate slugs for the time being.

### License

[](#license)

[SEO Aggregator](https://github.com/hettiger/seo-aggregator) is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

[SEO GEN](https://github.com/samkitano/seo-gen) is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![samkitano](https://avatars.githubusercontent.com/u/2251400?v=4)](https://github.com/samkitano "samkitano (6 commits)")

### Embed Badge

![Health badge](/badges/samkitano-seo-gen/health.svg)

```
[![Health](https://phpackages.com/badges/samkitano-seo-gen/health.svg)](https://phpackages.com/packages/samkitano-seo-gen)
```

###  Alternatives

[botman/botman

Create messaging bots in PHP with ease.

6.2k1.5M97](/packages/botman-botman)[denngarr/seat-fitting

Module to check fittings per character

1433.3k2](/packages/denngarr-seat-fitting)[thedmsgroup/mautic-enhancer-bundle

Various contact enhancer integrations for Mautic.

342.8k](/packages/thedmsgroup-mautic-enhancer-bundle)[xi/breadcrumbs-bundle

Xi breadcrumbs bundle for Symfony2 that utilises routes as a tree to build the breadcrumbs in order to not pollute the controller actions with repetitive breadcrumbs code.

113.2k](/packages/xi-breadcrumbs-bundle)

PHPackages © 2026

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