How to run (or should I run) PHP composer on Jelastic? - php

Basically what I'm trying to do is to create a simple multi-node env with varnish+nginx+mariadb+memcached. By now I've managed to launch the environment and attach git project to it. The problem is that we work with php and symfony2, which requires composer to be executed at least once in order to properly deploy the application.
Outside of jelastic we use Jenkins + Ant (but we don't scale horizontally in automatic on the projects where this setup is used, so it's not a problem to add node manually).
So the question is: How can I run composer or ant with build.xml on each deploy?
I see that Java environments have a build server option, is there something like this for php environments?

PHP projects do not have a "standard" build server in the way that many Java projects do - requirements for PHP build tools are more varied depending on the particular project.
For example one customer may ask for grunt, another for ant, and another for phing.
If you want to perform a sophisticated build, you can create your own build node for your PHP project using an Elastic VPS or separate Docker environment. To deploy the built project to your servers you can use SSH connections, or simply git push and set the runtime environment to auto-update (e.g. via ZDT feature) from that git repo / branch.
If your needs are more simple, you can install composer directly onto your php runtime node in the normal way via SSH.
E.g.
$ curl -sS https://getcomposer.org/installer | php
There are more detailed tips about how to tidy that up (add to your PATH etc.) at http://kb.layershift.com/jelastic-install-composer

Related

how to make installer of a web app in angular,mysql , php, and node

I have created a application that uses angularjs and php and nodejs as backend and redis as a caching server, now i want to create a installer that can package the installation of php mysql and nodejs and of my angularjs code in one application and run it in localhost how can i do that.
There is no defined tool for such a process. But out of the box you may use a docker container or npm pkg module which you can bundle your node backend server and the angular into a exe or platform independent bundle.
But pkg module cannot be used to bundle the php (But you may able to use php executable externally).
Check out these links
Docker
pkg
Anyway this is not a simple process, will be lot of overheads since the toolbox that you are using is not built for what you are trying to do.

Do I Need Composer, Git or Any of These after Project Is Finished?

For example:
I have a Homestead with Laravel in Virtual Machine. After I finish my project could I just copy the files and bring them to my Wamp server, and export the database and import it into Wamp?
Or is there more behind all this?
Yes, generally this could be one way to deploy a project to a server.
The question is a bit broad to give a good answer because there are many ways how to built a good project deploy chain. First of all it depends on the server you are deploying to and the access rights you have (e.g. are you allowed to ssh into the server or can you run git at your server).
If you have ssh access and you are able to run git a good way could be to pull the git project from your git server, run composer install and migrate and seed your database with artisan.
There are even more ways up to full integrated deploy chains where you just need to push your project to a git server to trigger a deploy (e.g have a look at Capistrano or Laravel Forge for automated deploy).

How to move Symfony2 application from localhost to deployment server (LAMP CentOS)

I have developed a Symfony2 app on my local machine. I access it using PHP's built-in server, via http://localhost:8000/
Question: how do I move this application to my VPS (LAMP CentOS) so that it can be accessed like this:
http://example.com
and is it any different for installing it on:
http://subdomain.example.com
PLEASE if by any chance you can provide a step by step instructions, it will be much appreciated and I'm sure useful to many others too. I'm used to working with stuff where you can simply move files from one place to another, update some config data and it works (Wordpress, coding without frameworks etc.)
The best solution to me is to have your project in a versionning system like git or svn without the vendors dir of course ...
This way, your simply have to do :
1) git clone your project into the prod dir
2) php composer.phar install to install your vendors
2b) create the mysql user with correct login and password according to your parameters.yml
3) php app/console doctrine:database:create to create your database with the credentials you set up in mysql
4) php app/console doctrine:schema:update --force to perform the database tables creation
5) testing the project :)
If you are not using a versionning system just upload your project to your server with an ftp software without the vendors directory ( it will be feeded by step 2) then perform 3rd , 4th and 5th steps !
For the subdomain part of your request you have to creats a subdomain folder on your server ( by using plesk if you have it ) or by manually creating a vhost config to specify the sub domain path. I can t provide you an example right now ( i m writing this from my mobile device and i don t have clear step by step procedure in order to achieve this )
[Install your environment]
So, First you need to install and run an apache Server. Find here the minimum basics to get your application running under Apache2. Then make sure you've PHP5 and MySQL up and running. Otherwise check,
Install and Configure MySQL Database Server
Installing and Configuring PHP
[Deploy your application]
Deploying can be a complex and varied task depending on your setup and
needs - Symfony.com
It's then up to you to choose the right way to deploy your application, you can do it,
Using Basic File Transfer
Using Source Control
Using Build scripts
I would recommend using Capifony which was build on top of Capistrano to adapt it to Symfony applications.
[Post-Deployment Tasks]
Your deployment process should be tailored to guarantee that all the required post-deployment tasks (Like updating your dependencies, setting your application configuration files, clearing the cache and dumping your assets, etc) are executed.
To get the big picture, read the How to deploy a Symfony2 application of the Cookbook.

Jenkins + Phing: Who should deploy and who should clone?

I have Jenkins setup to build and deploy my project using Phing.
Inside the Phing build.xml file, I create a set of targets for doing useful stuff, such as running tests, static code analyzer and such.
Phing also is responsible for deploying the application, creating a structure similar to this:
var/www
current -> /var/www/develop/releases/20100512131539
releases
20100512131539
20100509150741
20100509145325
features
hotfixes
The thing is, Jenkins does a git clone of the project and Phing also does it, inside the releases directory. With this, I have two clones on the same build and deploy process.
My question is: the responsibility of cloning the repository should be of Phing or Jenkins?
I leave Phing the same sort of tasks you mentioned: like static code analyzer, running tests, linters, etc.
The reason for this, is that as a dev, I might want to run all these test (or a set of them) regularly during my development, and Im able to trigger them on my local environment without the need of jenkins.
For deployment stuff, I leave jenkins in charge of it, so would leave jenkins to continue doing it.
But, if you want to have everything in phing, I think that would be ok, too. I would split the tasks to have a group of dev test to be run on console, and a jenkins tasks to be run on the deploy.
Definitively, only one of them should be doing so.

Is this a proper use of Jenkins?

We're a web development shop using PHP or .Net. Here's the proposed path for development:
Developer -> SVN Server -> Jenkins Server -> Dev Server
A developer commits or creates a tag to the SVN Server
Either a commit or tag triggers a job on Jenkins asynchronously
The job on Jenkins will run a svn update (or clear destination space, then svn export) on Dev Server bringing the code in from the SVN Server
For .Net, after having copied the code, I need to compile it using aspnet_compile
My question is two fold, is this a proper use of Jenkins? And, if I were to compile .Net using aspnet_compile.exe, would installing a slave on the Microsoft OS be the way to go (to enable this)?
To futher the answer:
Check the Restrict where this project can be run, select slave.
This sounds like a fairly standard build / deploy workflow and therefore a good use of Jenkins, but I'd suggest doing step 4 as part of your Jenkins build and then deploying the compiled artifacts to your dev server also using Jenkins. This way you'll be able to have Jenkins report compilation problems as build failures and have the ability to run tests against the compiled code as part of the Jenkins job, per #thescientist's comment.
If your Jenkins master is running on an operating system other than Windows, you can use a Windows slave to do the compilation. You could even have the slave process running on your dev server to make deployment easier; I wouldn't recommend this for a production setup, but it's OK for dev.
Here are some links which may help you:
Running Jenkins on Windows
Building ASP.NET code with Jenkins
Jenkins and PHP

Categories