Prosper Tech Web Dev

Wednesday, January 25, 2012

Symfony2 Services Notes

A service has a class, arguments to pass in on instantiation (can be other services @mailer) (must be present in constructor)

arguments can be optional (@?my_mailer),

outside of the constructor, with the calls: yml line under class, e.g. - [ setMailer, [ @my_mailer ] ]

services are by default public.

If two services have common dependencies or calls requirements, extend each from an abstract, and use parent: abstract_class_name for each service,

with the abstract defined higher up - set with abstract: true, and the calls on these.

You can override the calls parameter on the service that extends a parent, by adding calls to this too, and using the same key. Note that it is then called twice, so if you want to add to an array you can (otherwise it gets replaced with the last call). You could remove parent param from extender to stop this.

Factories can be used to make a service (if more complex than just passing other services in as arguments), first define the factory,

then use factory_service: yml line referencing the factory key. For the method used within this factory, define it as factory_method: , e.g. get.

For arguments you wish to pass into the get method, use arguments: - an array - @templating for example.

Services can have tags, which implies that the service is to be used for a specific purpose.

Sunday, December 05, 2010

PHP5.3 on Ubuntu Lucid Lynx 10.4

I found myself needing to install PHP5.3 on a new install of Ubuntu Lucid Lynx 10.4 recently, here's how I did it:

followed:
http://www.robsearles.com/2010/03/17/installing-php5-3-on-ubuntu-karmic/

Had to get libicu38
https://launchpad.net/ubuntu/hardy/amd64/libicu38/3.8-5

Had to remove the newer version of libkrb - which removed apache and everything (couldn't ssh in after this - so need to then
apt-get install openssh-server

wget http://us.archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.4~beta1-5ubuntu2_amd64.deb

aptitude install libicu38 apache2 apache2-mpm-prefork mysql-client-5.1 mysql-server-5.1 php5 php5-cli php5-mysql libapache2-mod-php5

set timezone in /etc/php5/apache2/php.ini :
date.timezone = Europe/London

I also wanted mod_rewrite:
sudo a2enmod rewrite

aptitude install curl curl-ssl php5-curl

/etc/init.d/apache2 restart

Hope this helps someone.

Saturday, October 09, 2010

XDebug using a Parallels VM and PHPStorm 1.0.2

I wanted to get XDebug working with my new IDE of choice: PHPStorm. I'm running a Parallels Virtual Machine (VM) with Ubuntu on it, and sharing my local folder on my Mac running Leopard.

I already had PHP 5.3.2, Apache 2.0 and mySQL running on the VM.

I installed XDebug using:
apt-get install php5-xdebug

This added a file named: "/usr/lib/php5/20090626+lfs/xdebug.so"

I then went in to /etc/php5/apache2/php.ini and added the following lines to the bottom:

zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=10.211.55.2
xdebug.profiler_enable=1
xdebug.profiler_output_dir=/tmp
xdebug.remote_log="/tmp/xdebug.txt"

I also checked there was no zend lines referring to zend debuggers etc, which conflict.

The IP I used above was not the IP of the VM as reported when using ifconfig on the VM, it was instead the IP of my host machine (my mac):

ifconfig on my mac:


















I added a file phpinfo.php with to see the xdebug settings:



I now needed to set up PHPStorm to use this configuration:

Under: Run > Edit Configurations in PHPStorm:



Clicking on Server path mappings:



Above, I made sure to use the mount point that the VM was using - this was configured using Parallels > Virtual Machine > Configure > Shared Folders options tab previously when setting up my VM.

I had mapped the /media/psf/ mapping to /var/www/ using a symlink. ( ln -s)

Here is the server configuration



and the mappings tab:



I made sure my VM Apache was restarted:
/etc/init.d/apache2 restart

Now to debug, I could click the Run > Debug option in PHPStorm.

I hope this helps someone. Any questions, please email nathan [ at ] eit dot co dot nz.





Monday, June 14, 2010

GIT with CruiseControl

To get GIT to work as a plugin within cruisecontrol, you need to configure like this:

<plugin name="git" classname="net.sourceforge.cruisecontrol.sourcecontrols.Git" />

This is not obvious when looking here:
http://jpablobr.com/php-staging-environment-for-continuous-integration-part-2/

The resulting config.xml file will look like this:


<cruisecontrol>
<project name="socialgo" buildafterfailed="true">

<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
</listeners>

<modificationset quietperiod="60">
<git localWorkingCopy="projects/${project.name}/source/"/>
</modificationset>

<plugin name="git" classname="net.sourceforge.cruisecontrol.sourcecontrols.Git" />

<bootstrappers>
<antbootstrapper anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml" target="build" />
</bootstrappers>

<schedule interval="300">
<ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml"/>
</schedule>

<log>
<merge dir="projects/${project.name}/target/test-results"/>
</log>

<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/target/${project.name}.jar"/>
</onsuccess>
</publishers>

</project>
</cruisecontrol>










Wednesday, March 24, 2010

Calum's website

Calum Ryan ( @zizzfusion ) is offering a free pizza voucher prize - and although I love pizza, I'm always interested in commenting or helping on any website designs that people ask for feedback about.

The website is: http://www.zizzfusion.com/

The things that I like:
- that smokey look at the top
- easy to see fresh articles from the homepage - with comment count as bubbles.
- simple top right navigation
- a contact form on the homepage
- flickr photos
- screen shot popup - love these things.

The things I would change (if I had time - and yeah, I never do have time so I understand):
- the positioning of the popup about this competition - overlays the logo - could do with a cookie check to see it doesn't show again when refresh the homepage, but ideally slide it in, and position it so it doesn't look like an overlay banner advert.
- when viewing on 1024*768 there is no margin and slightly to wide, so the nice circle to the right is cut off and a unnecessary scroll bar appears.
- the logo is a bit flat - could do with some backdrops and colour contrast
- the logo does not appear on all pages - so I could be mistaken for looking at another website when going to the portfolio page
- portfolio page calls "articles" "tutorials"
- navigation doesn't show which page you are currently on
- Article category buttons only work for text area - expect the whole button to be clickable
- screen shot popup needs a close button at the top.
- could enhance the portrait picture on the portfolio page as it's very dark.
- description in meta tags could be stuffed with more keywords like "design, webdesign, london etc.. - not exceeding 156 characters of course.


With a few tweaks this could be a great website!

Wednesday, December 30, 2009

Ignoring files in a GIT repository

To ignore a file:

if the project is /work/project
you have /work/project/.git folder
If you want to have the files ignored over all pages, create a file called:
/work/project/.gitignore and put one line for each file, relative to /work/project, eg:
I have a /work/project/src/cache folder which I want to have its contents ignored (any files within the /work/project/src/cache folder, so I put in .gitignore:
src/cache/*

then make sure there are none of these files in the cache folder already:
git rm --cached src/cache/*

Then, the standard commit - note, you may need to directly add .gitignore:
git add .gitignore
git commit
git push projecthostnamehere branchnamehere

For the same project, if you want to ignore on just this local copy, edit:
/work/project/.git/info/exclude

Note, you don't have to add this change, but you do need to rm anything that was there before, as it only ignores it once it is removed (see git rm --cached src/cache/* above)

Thursday, June 18, 2009