CodeIgniter: development and production environment

I am currently studying the CodeIgniter PHP framework. I am currently looking for a DEV environment and a PRODUCTION environment. Based on pure C and JAVA backgrounds, I’m used to having everything locally (with version control), but since I will have the PRODUCTS side on the website, I was interested in several different things:

  • Is it better to maintain a local DEV environment?
  • What would be a good (and easy) way to make changes on the DEV side to bring them to the PRODUCTION side (assuming DEV env is local)?
  • Is it possible (and if so, how?) To configure CodeIgniter to have a DEV and PROD environment in the same code space (say, on a server, but with different database tables)?
  • When using version control in an application that I created in the Framework, is it only recommended that I create the files for my application or add the whole structure (so that the code is compatible with the version of the Framework)?

I appreciate any thoughts or suggestions you have in advance.

Thanks!

+6
version-control php frameworks codeigniter
source share
2 answers

I do not use CodeIgniter, so I can not answer all your questions; but, nevertheless, here are a few pointers:

  • Development environment: I like when each developer has his own environment; and it’s generally easier / faster when it is on his machine
    • still, if your development machines are running Windows and your server is running Linux, this may cause some problems (there are several differences between the two, for example, case sensitivity in file names).
    • in this case, if you have a sufficiently powerful computer, using VMWare or VirtualBox to run a minimalist virtual machine (with Linux + Apache + PHP + MySQL on it, the source of the code is also turned on, exported via the samba share) might be a good solution - this is which I did a little more than six months, and it works very well.
  • Pushing changes from dev to prod:
    • one solution is to register on the production server and update "svn update"; but I don’t really like it (if some files were changed directly on the production server - yes, this sometimes happens), you may encounter conflicts, etc .; and it’s definitely not funny at all, as it could break the site ^^
    • I like one solutioon more (it takes more time to deploy, but if you deploy only, say, once a week, it’s quite normal - and definitely more secure) - use "svn export" on one of the dev machines, create a tar / zip archive / any other and upload it to the prod server. Then you extract it to the NEW directory; and when this is done, you will change the symlink to point your root directory to this new directory. The good thing: you keep the old sources on the production server, and if there is a catastrophic problem with what you deployed, you only have one symbolic link to go back to the previous version - and this may someday save the day ^ ^
    • oh, and as a side element: you have to write a script to do it automatically for you: this will avoid a one-step mess for one day when you do it manually (and help the day when the guy who always does it on holidays ^^)
  • About using one instance of sources for both environments: even if you plan to do this only for the framework, I would not recommend it:
    • it means having dev and prod on the same machine, which is bad: what if some others in the development of the script get crazy and do bad things? What if one developer enters some kinf from "rm -Rf" into the wrong directory?
    • You thought about different database tables (I'd rather go with different databases, with different users, to avoid anyone making any bad query in the wrong database!), But this is not the only one: how about temporary files? cache, for example?
    • I would rather have fully disassembled instances; even if it means that the sources / structure is twice on the machine - and I really recommend having two different machines!
  • About creating a structure on SVN:
    • The more things you have on SVN, the easier it is to create a new development environment: ideally, there is only one “svn checkout”, and there the new environment is ready for a new developer who has just joined your team; in combination with Virtal Machine, you can give it (copied from another machine), you can have developers ready to work on your project in a couple of tens of minutes - that's nice ,-)
    • However, the presence of the Framework in SVN is PITA to update it: you have to remove it, replace it, re-commit, ...
    • Using svn: externals (depending on your installation / structure if you can) pointing to the SVN server itself can be a good thing to always be up to date (it is not necessary to point to HEAD; using a tag or branch may be enough for you) .

Hope these few notes help ...
Enjoy!

+7
source share

1) I agree with Pascal MARTIN - the best for everyone who has their own local environment for developers; that way they can play without stepping on each other. This may mean that you want to have some type of test or intermediate environment where team members (and project stakeholders) can see the integrated code in the development process.

2, 3). In general, it seems you are asking how to automate / deploy to one or more environments. There are several commercial and open source for this. We recently started using Capistrano ( http://www.capify.org ) and were really pleased with the results. It is a ruby ​​tool and it is written using ruby ​​rails. If you are not familiar with these (I was not), it takes a little reading and google to figure it out. However, it is simply based on a means of defining and running scripts on remote servers. These scripts can be used for any type of deployment (for example, we use PHP). Two important things about Capistrano that solve your question:

  • He knows about version control; regardless of whether you use SVN, git or others, he knows (several ways) to pull the latest code from the repository and do whatever is necessary to update the remote servers.
  • These are transactions, therefore, if something goes wrong with the build / deploy process, it may automatically roll back to the previous version.

4) This is probably a simplified model; just download the codeigniter installation and write your code in the applications / directory. This may be a problem someday if you want to upgrade CI to take advantage of some of the new hot features. You can get around this by specifying the external link svn: codeigniter so that when upgrading it is also included in your code. See http://svnbook.red-bean.com/nightly/en/svn.advanced.externals.html for more information ...

+1
source share

All Articles