Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use git with Symfony 2?

I installed Symfony 2 with Composer (following the 'master' guides), and it created this .git/config file:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git://github.com/symfony/symfony-standard
    pushurl = [email protected]:symfony/symfony-standard.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "composer"]
    url = git://github.com/symfony/symfony-standard
    fetch = +refs/heads/*:refs/remotes/composer/*

I don't want to interfere with what Composer did here since I don't know how it works, and I want to be able to update the vendors in the future.

So how do I add my own repository for 'myapp' and commit/push to it? I usually do 'git remote add origin ...' and only work with that, but now there are two repositories in the file, plus the one I need to add.

UPDATE

I installed Symfony2 with this command:

$ php composer.phar create-project symfony/framework-standard-edition myapp

This created myapp/ and installed Symfony2 + dependencies. But now composer.json does not look like it's ready to use for my project, it looks like my project is Symfony2 itself (I think):

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
    "psr-0": { "": "src/" }
    },
    "require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.1.*",
    "doctrine/orm": "2.2.*",
    "doctrine/doctrine-bundle": "dev-master",
    "twig/extensions": "dev-master",
    "symfony/assetic-bundle": "dev-master",
    "symfony/swiftmailer-bundle": "dev-master",
    "symfony/monolog-bundle": "dev-master",
    "sensio/distribution-bundle": "dev-master",
    "sensio/framework-extra-bundle": "dev-master",
    "sensio/generator-bundle": "dev-master",
    "jms/security-extra-bundle": "1.1.*",
    "jms/di-extra-bundle": "1.0.*"
    },
    "scripts": {
    "post-install-cmd": [
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ],
    "post-update-cmd": [
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ]
    },
    "config": {
    "bin-dir": "bin"
    },
    "minimum-stability": "dev",
    "extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web"
    }
}

Master Guides

  • http://symfony.com/doc/master/book/installation.html (for the first step, which is downloading symfony, I used the composer command, as shown here: http://symfony.com/download)
  • http://symfony.com/doc/master/cookbook/workflow/new_project_git.html (this one seems to be outdated, since it says we have to do 'git init', but the git repo is already created by composer)
like image 656
ChocoDeveloper Avatar asked Jul 19 '12 18:07

ChocoDeveloper


1 Answers

You can safely remove the .git folder and run git init to initialise your own repo just like @m2mdas suggests.

Composer is not doing anything special here. It just clones the symfony-standard project and then installs its dependencies.

Composer clones the repository but it doesn't need the .git folder to work. In fact I don't think it should be cloning projects by default. Might be they'll fix it in future versions.

Composer uses composer.json file and you should manage all your dependencies with this one file. You can safely edit it to add or remove packages.

Then, to update packages just run:

php composer.phar update

All the packages removed from composer.json will be removed, those you added will be installed. Existing packages will be updated to the latest version.

You should store the generated composer.lock file in your repo to be sure you'll always get the same versions of dependencies when you run:

php composer.phar install

composer.lock is updated when you first run install and with every update command.

like image 86
Jakub Zalas Avatar answered Oct 25 '22 17:10

Jakub Zalas