PHPackages                             dataspring/demo-bundle - 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. dataspring/demo-bundle

ActiveSymfony-bundle

dataspring/demo-bundle
======================

Demo Bundle

0.1.5(10y ago)121MITPHPPHP ~5.3

Since Apr 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/guobinqiu/DemoBundle)[ Packagist](https://packagist.org/packages/dataspring/demo-bundle)[ Docs](http://github.com/guobinqiu/DemoBundle)[ RSS](/packages/dataspring-demo-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (7)Used By (0)

Create your own Symfony2 bundle
===============================

[](#create-your-own-symfony2-bundle)

Tutorial of creating your own Symfony2 bundle

How to do?
----------

[](#how-to-do)

### 1. Install Symfony

[](#1-install-symfony)

[http://symfony.cn/docs/quick\_tour/the\_big\_picture.html](http://symfony.cn/docs/quick_tour/the_big_picture.html)

### 2. Create a new empty symfony project

[](#2-create-a-new-empty-symfony-project)

```
symfony new DemoBundle 2.3

```

(**2.3** is my symfony version)

### 3. Enter into the project directory

[](#3-enter-into-the-project-directory)

```
cd DemoBundle

```

### 4. Generate a new bundle

[](#4-generate-a-new-bundle)

```
php app/console generate:bundle

```

this will ask you to answer questions. For Bundle namespace set to *DataSpring/DemoBundle* (CompanyName / BundleName).

### 5. Enter into the bundle directory

[](#5-enter-into-the-bundle-directory)

```
cd src/DataSpring/DemoBundle

```

### 6. Init your github repository

[](#6-init-your-github-repository)

Create a new repository in your github first then run the following command lines:

```
git init
touch README.md
git add .
git commit -m "initial commit"
git remote add origin git@github.com:YourAccount/DemoBundle.git
git push -u origin master

```

### 7. Add a composer.json file

[](#7-add-a-composerjson-file)

In the `src/DataSpring/DemoBundle/` folder, manually add a `composer.json` file.

or run

```
composer init

```

to get a simpliest file before changing it.

A composer.json file would look like so:

```
{
    "name": "dataspring/demo-bundle",
    "description": "Demo Bundle",
    "type": "symfony-bundle",
    "keywords": ["dataspring"],
    "license": "MIT",
    "homepage": "http://github.com/guobinqiu/DemoBundle",
    "authors": [
        {
            "name": "Guobin",
            "email": "qracle@126.com"
        }
    ],
    "require": {
        "php": "~5.3"
    },
    "autoload": {
        "psr-4": {
            "DataSpring\\DemoBundle\\": ""
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "0.1.x-dev"
        }
    }
}

```

### 8. Add a MIT license file

[](#8-add-a-mit-license-file)

In the `src/DataSpring/DemoBundle/` folder, add a `LICENSE` file

>

Your can borrow from the above licence reference as your own license content. Also see [LICENSE](https://github.com/guobinqiu/DemoBundle/blob/master/LICENSE)

### 9. Create a controller and its routing

[](#9-create-a-controller-and-its-routing)

Controller Code:

```
