I've developed an application which uses the Symfony 2 framework. The application code resides in a Bundle, and on my local machine I just downloaded the Symfony2 Standard Distribution and added the Bundle to the src folder as the tutorials describe, before editing the config / routing files appropriately. That's served me well from a development perspective.
I'm now starting to think about how to handle the framework dependencies with regards to deploying to a production environment / a continuous integration setup. Should I continue as I have to date, using a distribution and perhaps a build tool like Phing to check out my bundle and any other dependencies? Or should I be checking out only the Symfony source from Github, and maintain a custom 'distribution' for my application?
I'm hoping someone else has had to do a similar thing and can recommend a solution that works with minimum fuss!
Thanks.
Are your tests written with PHPUnit? If so you can run the tests directly using ant, and then run Ant from jenkins. In my set-up I then have a second project that updates the git checkout in our staging environment if the test passes. I ran into a bunch of issues duck-taping this all together ( mostly around github keys, user permissions, user shell environments, etc ) but the phpqa tools work very well. I just saw this post that seems like a more recent guide on getting everything running:
http://edorian.posterous.com/setting-up-jenkins-for-php-projects
I've got this 'Hello world' project including a working build.xml that should work if ant and the PHP tools are set up correctly:
https://github.com/canuckistani/JenkinsTest
Related
We are working on a Magento payment module, let's call it ABC. We are using Docker for the development. So, for development, we are using a Magento image and adding the module code to the htdocs/app/code via volumes from docker-compose.yml. Our Github repo contains the module code only. We have added some tests for the module under app/code/ABC/Payment/Test folder. We want to setup a Github workflow that will run the test automatically on pull request.
The issue is some of the code depends on the Magento core classes like Magento\Framework\App\Config\ScopeConfigInterface, Magento\Store\Model\StoreManagerInterface and so on which won't be available in our Github repo. Is there any Github actions with which we can setup Magento, copy the module codes into it and run the module's tests?
Any help would be greatly appreciated. We are unable to figure this out.
You could require magento using composer within your github workflow. https://github.com/marketplace/actions/composer-php-actions
If you use grumphp (https://github.com/phpro/grumphp) you can have a look at this example: https://github.com/phpro/phpro-mage2-module-translations/blob/master/.github/workflows/grumphp.yml
You have not shared much about what precisely is making you unable to figure it out for Github Actions, however reading your question it looks to me like you already have figured out for development: Using Docker.
Now Github Actions as well supports Docker. All you need is to run the setup script for the development environment that establishes that Docker setup within the Github Action before running your tests.
You may want to add an additional environment for it, so that you can branch between the development system and Github Actions, but theoretically it should already work without.
Then after you have cloned the code, and then setup the Docker environment, execute the tests in the Github Action. The tests should run now.
I have developed a symfony application and it's done.
It's been a couple of days and I can't figure out how to deploy this into a real apache server, when I copy it to the public_html it doesn't work assets don't load properly.
Can some one give me a step by step description of how to deploy it so that when I navgiate to example.com url I see my symfony application.
Thank you
If you try to deploy your application on a server, you have to configure apache. The best way its to make a virtual host.
Here the documentation:
http://httpd.apache.org/docs/current/en/vhosts/examples.html
http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html
I would suggest using Capifony which provides a specialized set of tools on top of Capistrano, tailored specifically to symfony and Symfony2 projects. (according to the documentation)
The advantages of using capifony are,
deploying is as simple as running cap deploy from your project root directory.
It stores multiple releases.
It allows you to use SCM(s) to pull your application code down to the server.
You can configure it to run any batch command during the deployment.
It performs a transactional-like deployment process (if any step fails, the deployment is
rolled back and the current directory points to your last release)
You'll also need to troll through this part of the documentation to figure out how to get your application running under Apache.
Currently using LAMP stack for my web app. My dev and prod are in the same cloud instance. Now I am getting a new instance and would like to move the dev/test environment to the new instance, separating it from the prod environment.
It used to be a simple Phing script that would do a SVN export into the prod directory (pointed to by my vhost.conf). How do I make a good build process now with the environments separated?
Thinking of transferring the SVN repository to the dev server and then doing a ssh+svn push (is this possible with Phing?)
What's the best/common practice for this type of setup?
More Info:
I'm currently using CodeIgniter for MVC framework, Phing for automated builds for localhost deployment. The web app is also supported by a few CRON scripts written in Java.
Update:
Ended up using Phing + Jenkins. Working well so far!
We use Phing for doing deployments similar to what you have described. We also use Symfony framework for our projects (which is not so much important for this but Symfony supports the concept of different environments so it's a plus).
However we still need to produce different configuration files for database, front controllers etc.
So we ended up having a folder with build.properties that define configuration for different environments (and in our case also for different clients we ship our product to). This folder is linked to the file structure using svn externals (again not necessary).
The Phing build.xml file then accept a property file as a parameter on the command line, takes the values from it and produces all necessary configuration files, controllers and other environment specific files.
We store the configuration in template files and then use copy/filter feature in Phing to replace the placeholders in the templates with the specific values.
The whole task of configuring the given environment can then be as simple as something like this:
phing configure-environment -DpropertyFile=./build_properties/build.properties.prod
In your build file you check if the propertyFile property that specifies the properties file is defined and load the file using <property file="./build_properties/build.properties.prod" override="true" />. Then you just do any magic with the values as you need.
You can still use your svn checkout/update and put all the resulting configuration files into svn ignore (you will have them generated by phing). We actually use additional steps in Phing. Those steps in the end produce a Linux shell installation self-deploy package. This is produced automatically in Jenkins. We then send the package to our clients or the support team can grab the package from Jenkins and they can do the whole deployment just by executing it (we still prefer manual deployments to production servers) or Jenkins can deploy it automatically (for example to test servers).
I'll be happy to write more info if needed.
I recommend using Capistrano (looks like they haven't updated the docs since they moved the site) and railsless-deploy for doing deployment. Eventually, you are probably going to need to add more app boxes and run other tasks as part of your deployment so choosing a framework that will support this can save you a lot of time in the future. I have used capistrano for two PHP deployments (one small and one large) and although its not perfect, it works well. It also handles all of the code checkout / update, moving symlinks into place, and rolling back if something goes wrong.
Once you have capistrano configured, all you have to do is something like:
cap dev deploy
cap prod deploy
Another option that I have explored for doing this is fabric. Although I haven't used it, if I had to deploy a complex app again, I would consider it. The interface is simple and straightforward.
A third option you might take a look at thought its still in the early stages of development is gantry (pardon the self promoting). This is something I have been working on out of frustration with using capistrano to deploy a PHP application in an environment with a lot of moving pieces. Capistrano is great and works well for non PHP application deployments, but you still have to some poking around in the code to understand what is happening and tweak it to suit your needs. This is also why I suggest giving fabric a good look.
I use a similar config now. Lamp + SVN + codeigniter + prd and dev servers.
I run the svn repos on dev. I checkout the repos into the root folder of the dev domain. Then use a post-commit hook to update the root folder everytime any developer commits.
When we are happy and have fully tested the code I ssh into the prd server and rsync the dev root to the prd root.
Heres my solution for the different configs. Outside the root folder I have a config.ini file. I parse the file in my codeigniter constants.php script. This means that the prd and dev server can have separate settings without them ever being in the repos.
If you want help with post-commit, rsync and ini code let me know.
I am interested in the PHP framework, especially by symfony and ZendFramework, but I am not sure of one thing: I saw the need to type command lines to create a project with these frameworks. Ok, but once the project is finished, is it possible to move files to another server without installing anything (except for Apache)?
Thank you in advance
Ps: No report, but do StackOverflow uses a framework?
It is absolutely possible to run a symfony or zend framework application without installing the framework on the server. Symfony has a special mechanism to pack everything into one folder. If you use zend framework you basically have to copy the "Zend" folder to your "lib" directory and you are ready to go.
As far as I know, StackOverflow is build on ASP.net and C# running on several windows servers.
Firstof, most of those commands are needed for development only. But also you do not have to have the commands in your global path, it's also possible to execute the scripts directly.
In case of symfony that would be something like
./symfony-framework/data/bin/symfony
if you installed symfony to symfony-framework.
I believe stackoverflow is based on .NET MVC or plain ASP .NET - http://meta.stackoverflow.com will give you that answer
With Zend Framework, it is possible. The Zend_Tool part, which sets up the basics of your project is just addition. You can, but you don't have to use it at all. You can just write the project from scratch yourself, just stick to the standard project architecture.
Anyway, once the project is ready, it does not need any command line setup, other than mayby setting correct file system permission if your project needs to write some files.
I can't say about symphony, but I assume it also can be just copied to the target server.
I don't know, how about ZF, but project made with Symfony can be easily moved to another server just by copying files. However it will be difficult to maintain your project without commands. Also you have to copy all Symfony's core files to your server, but it will be better to install Symfony there before.
About Symfony:
Usually, you develop locally on your dev environment (using Wampserver or MAMP for example). You will require access to the command line to run symfony commands, specially for complex tasks like ORM tasks. So you have to install symfony on that environment.
According to the official doc the recommended installation method is through SVN (either the trunk or a tag) inside your project folder.
When you'll push the files from your dev environment to another (using project:deploy if you can), all the required files will be pushed.
So there is no need to install (in the sense of "run" or "execute") anything on the live environment server. The only "installation" method that requires an access to the command line is the PEAR install method, which is not recommended.
The only problem that I had when I deployed an application was a user permission problem on the cache folder, but that's easy to fix by changing the folder permission.
There's another post on SO relating to .NET -- not us. Pure PHP. Trying to find the best way/process to deploy stable version of our PHP app. I've seen an article on Capistrano, but am curious what else is out there. Aside from the obvious reasons, I'm also looking to add some scripting so that the SVN rev number gets added in there as well.
Much thanks.
I've used a home-grown script for quite some time. It will (based on an application configuration file):
Run svn export on the repository based on a tag.
Package the export into a tar or zip file, which includes the tag in the name.
Use scp to copy the package to the appropriate server (QA or release).
Connect to the server with ssh to install the package and run post-install scripts.
The application configuration file is part of the project. It can tell the script (at step 2) to strip paths and otherwise process specified files. It also specifies server names and how to handle externals.
I've recently migrated the script to support Git as well as Subversion. I'm also probably going to migrate it to PHP since we're now running in a mixed (Linux and Windows) set up, with Linux now in the minority.
I have plans to automatically call the script with post-commit hooks, but haven't had the need to implement that just yet.
Coincidentally, I was just reading about an Apache Ant/gnu make like build tool called Phing. What I like about it is the ability to write custom extensions in PHP!
I don't know if it works for deploying an app live, but phpUnderControl is a continuous integration suite (which I'm just now starting to look into). If it doesn't support doing deployments natively, it can probably be extended to do them.
Chris Hartjes has a nice view on this: Deployment is not a 4 letter word
We're using Webistrano, which is a web frontend for Capistrano, to deploy a few dozen projects. It's built as a Ruby on Rails app, and provides a nice, centralized and consistent user interface for Capistrano deployments.
Instead of having cap recipes in every project, and running command-line tools, Webistrano stores the recipes in its database, and allows you to attach the recipes to multiple projects and stages. This reduces duplication of scripts.
Also nice is that all deployment logs are stored so there's an auditing trail. Who deployed which revision to the live server, that sort of thing.
As you requested, the Revision number is stored in the deployed project as well.
All in all, we're very pleased with it.