2

After cloning an existing git repo to install a new fresh Symfony I got the error Project directory

symfony new . --webapp

This is because of the .git file generated after clonning the existing repo.

What is the recommended best practices/steps starting with an existing repo to install a symfony version ?

1
  • first create your project in an non-existed folder (or an empty folder) and then add your remote to git. Commented Jul 20, 2024 at 19:23

3 Answers 3

2

This is the same issue that happens when one tries to install Laravel with Composer in an freshly cloned empty git repository

composer create-project laravel/laravel .

enter image description here

So, since you already have an existing repo, the easiest workaround is to

  1. Create an empty temporary folder (name it something like temp) in the repo.
  2. Create a Symfony app inside of that temp folder.
symfony new temp/ --webapp 

For Laravel the equivalent command would be

composer create-project laravel/laravel temp/
  1. Now move the content from the temp folder to the one you want (can even drag it) and delete the temp folder.
Sign up to request clarification or add additional context in comments.

Comments

0

After cloning a fresh symfony git repo, you, probably, have a compose.yaml ready.

If, so, i suggest to launch this command :

symfony composer update

Comments

-1

The recommanded way is to create your project and then push it to some remote repository.

# This creates a folder named project-name
symfony new project-name

# Go inside this folder
cd project-name

# Add your remote repository
# When you create a repository on GitHub you can find this line in the main page of your repository
git remote add origin [address of the repository usually [email protected]:You/project-name.git]
git push --set-upstream origin main

You do the Symfony install first because it uses git to initialize the repository (and create the .git folder as well) to avoid you some commands at startup and you just have to push the init to the remote.

1 Comment

Yes but doesn't work if you need to use an already existing repo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.