How to change a Phoenix Project name smoothly?

I use mix paper to create a new project paper.

So all the stuff is called Paper or :paper.

However, I have to define a model called paper. So I have something like defmodule Paper.Paper do.

When I have multiple aliaes, I need to move Paper.paper to the last.

I know I made a “stupid” codename that may interfere with the model name.

So how can I modify all the Paper. stuff and :paper stuff eaisly? Is there a Phoenix mix command to do that?



There is not a command for renaming a project. I have however had to do so a couple times in the past, and in general global find and replace works really rather well. Just also move any directories named paper and you’re done.


Thanks a lot! I just want to know if others may have the same problem. In my following project I should be more careful about the namings.


A global find+replace works a lot better in Elixir than in most OOP-languages, because you always refer to a certain piece of code the same way: ModuleName.function_name. And structs use the ModuleName as well.

In OOP-languages, you can only hope that some object isn’t referred to under a different name.


I’ve been using this script for the two or three times I had to rename a phoenix project:

requires ack to be installed, but you could certainly swap that out for grep.



• Works on MacOS, not tested elsewhere.
• Needs: git, xargs and sed.

From the root folder of the project:

  1. git grep -l 'old_name' | xargs sed -i '' -e 's/old_name/new_name/g'

  2. git grep -l 'OldName' | xargs sed -i '' -e 's/OldName/NewName/g'

  3. mv ./lib/old_name ./lib/new_name

  4. mv ./lib/old_name.ex ./lib/new_name.ex

    If you have a similar folder structure in the tests folder, you probably also need:

  5. mv ./test/old_name ./test/new_name


@jaysoifer: you forgot about mv command for tests :smile:
Also you need to be careful using grep (no preview of changes), because some simple names could be also in other files like assets. Better way is to exclude some folders - just to be sure.
I suggest to use kfilereplace if you are using KDE/Plasma 5, because you can preview what files will be modified.



I’m running 1.3-rc1, I don’t see anything else missing, can you help me?

@jaysoifer: you could have same directory structure in test folder like in lib folder.


I am working on phoenix 1.3.0 , is possible to use the above command to change project name?

1 Like

Will this work for Phoenix 1.3?

1 Like
mv ./lib/old_name_web ./lib/new_name_web
mv ./lib/old_name_web.ex ./lib/new_name_web.ex


Since this is the first hit on google for this problem, I library that I’ve used a couple times for this problem is


Great library! Worked out great, the only was with it also change the DB name on dev.exs/text.exs etc which I had to fix manually but besides that - works great!

1 Like