x

A Daily-Symfony-Quick-Setup-Zen-Cheatsheet

#137

Making the transition to Symfony 1.2 and Doctrine all at once was never going to be easy. As Doctrine is the future of symfony and I have a distinct Propel addiction, the following steps (based on the early stages of the excellent Jobeet tutorial) will take no time at all and can be practised often to help cement the process in mind until it’s second nature.

This is no substitute for (and will make little sense without first reading) the Jobeet tutorial, nor the documentation. This is just my daily-Symfony-quick-setup-zen-cheatsheet. I hope in time to be doing this one-handed in my sleep while vaccuuming the stairs. Copy+Paste strictly out of bounds.

If you choose to use this and repeat it often, you’ll have setup your web server config’ on your development setup ready to run this, so those steps are omitted.

Posted here in a bit of a rush to respond to Jwage’s request , I hope they live up to expectation, and that someone finds them useful. I am bound to have made some errors, some omissions or not been concise enough, please let me know.

Create The Project

  • mkdir <path_to_local dev>\newsymfonytest
  • cd <path_to_local dev>\newsymfonytest

From now on<path_to_local dev>\newsymfonytest is your <project> directory

  • php <path_to_symfony>\data\bin\symfony generate:project newsymfonytest
    • Note that this creates an absolute path to Symfony in <project>/config/ProjectConfiguration.class.php which you should update.
  • copy the sf folder from  <path_to_symfony>\data\web\ into <project>/apps/frontend/web or alias it in your server configuration Alias /sf “<path_to_symfony>\data\web\sf”
  • Now Symfony is linked from your current location, the <project> root, test local access to Command-Line Interface with php symfony cc
  • Check the application has been created by visiting in browser

Setup Doctrine Database

  • Replace the setup function in <project>/config/ProjectConfiguration.class.php
public function setup()
{
  $this->enablePlugins(array('sfDoctrinePlugin'));
  $this->disablePlugins(array('sfPropelPlugin'));
}
  • Publish any plugin assets: php symfony plugin:publish-assets
  • Clear the Cache php symfony cc
  • Remove Propel structure, create Doctrine structure:
    • rm config/propel.ini
    • rm config/schema.yml
    • rm config/databases.yml
    • mkdir config/doctrine
  • create database in MySQL: mysqladmin -u root -p create newsymfonytest
  • << enter password when prompted or omit -p if you have no password set (shame on you!) >>
  • setup the YAML schema in <project>/config/doctrine/schema.yml

Here’s my sample schema.yml, lifted from the Jobeet tutorial:

# config/doctrine/schema.yml
SampleCategory:
  actAs: { Timestampable: ~ }
  columns:
    name: { type: string(255), notnull: true, unique: true }

SampleItem:
  actAs: { Timestampable: ~ }
  columns:
    category_id:  { type: integer, notnull: true }
    type:         { type: string(255) }
    is_activated: { type: boolean, notnull: true, default: 0 }
    email:        { type: string(255), notnull: true }
    expires_at:   { type: timestamp, notnull: true }
  relations:
    SampleCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: SampleItems }
  •  Generate a new Databases.yml:

php symfony configure:database –name=doctrine –class=sfDoctrineDatabase “mysql:host=localhost;dbname=newsymfonytest” <mysqluser> <mysqlpass>

Build!!!

  • php symfony doctrine:build-model
  • php symfony doctrine:build-sql
  • php symfony doctrine:insert-sql
  • php symfony doctrine:build-forms

Add Sample Data

Create fixture files:

Here’s my sample <project>data/fixtures/categories.yml, again lifted from the Jobeet tutorial:

SampleCategory:
  design:
    name: Design
  programming:
    name: Programming
  manager:
    name: Manager
  administrator:
    name: Administrator

Here’s my sample <project>data/fixtures/items.yml, curiously similar to one from the Jobeet tutorial I’ve said so little about.

SampleItem:
  job_sensio_labs:
    SampleCategory: programming
    type:         full-time
    is_activated: true
    email:        job@example.com
    expires_at:   '2010-10-10'
  • Populate with php symfony doctrine:data-load

Generate first app

  • php symfony generate:app –escaping-strategy=on –csrf-secret=1sTh15r34l1y53cur3 frontend
  • Visit the site root you set up in your server configuration in your browser

Generate first module

  • Then, using the format:
  "php symfony doctrine:generate-module --with-show --non-verbose-templates <appname> <modulename> <modelname>"

php symfony doctrine:generate-module –with-show –non-verbose-templates frontend sample SampleItem

  • Visit the module in your browser
  • Rinse and repeat

Practical Archaeological Excavation Techniques, day six

#136

Thursday November 6th, 1130 – 1700. Mild for the time of year, sunny then overcast (arguably the ideal weather for it)

Having now covered excavation, identification, the recording system for trenches, finds, contexts, photographs, basic observations and interpretation, today I set about my first graphic site recordings.

Read the rest of this entry »

Background Animations in Script.Aculo.Us

#135

Inspired by Jonathan Snook’s article on animating backgrounds using Jquery, I had a snoop around in Script.aculo.us for the equivalent methods to create moving background images. It wasn’t long before I hit a wall with the Effect.Morph method and its inability to parse the CSS values for background-position.



Effect.Morph simply examines current CSS values and calculates new ones, iterating through a number of transforms according to the duration of the morph. Colour values are handled appropriately, but for positioning only a single value is anticipated. As the second value of background-position is never parsed, you’re limited to horizontal animation.

see a demo of the problem.

So I’ve created an extension, similar to Alexander Farkas’ for JQuery, to manipulate background-position both vertically and horizontally using the same syntax as Effect.Morph.

See it in action on Horizontal and Vertical background animations and Vertical only.

Using the Effect.Morphbgpos extension

Include in the <head> the Prototype and Script.aculo.us libraries as usual. Download the extension and include it after the main libraries:

<script src="bgposeffect.js" type="text/javascript"></script>

Jonathan did a great job describing his HTML and CSS markup (including how to show the final states of the animation using CSS just in case Javascript is not present) so I won’t repeat it all here. Suffice to say this is very similar: an unordered list with an id, containing three items, containing only links.

<body>
...
<ul id="a">
	<li><a href="#">Rivera</a></li>
	<li><a href="#">Miro</a></li>
	<li><a href="#">Varo</a></li>
</ul>
...

Then (somewhere after the list) include the code observers that restyle your links on mouseover and mouseout:

<script type="text/javascript">
$$('#tabs a').each(
	function(s) {
		s.observe('mouseover', function(s){
			this.setStyle( {backgroundPosition: "0px 5px"});
			new Effect.Morphbgpos(this, {
			  style: 'background-position:0px -40px;color:#cc0000',
			  duration: 4.3
			});
		});
	 	s.observe('mouseout', function(s) {
			this.setStyle( {backgroundPosition: "0px -40px"});
			new Effect.Morphbgpos(this, {
			style: 'background-position:0px 5px;color:#c0c0c0',
			duration: 4.3
			});
		});
	});
</script>

Note that in the example each of the observer methods sets the state directly before animating it. Mouseover begins from the original state set in the CSS while Mouseout sets the finished state (as in the CSS link hover state ) before animating back to the original state.

How it works

Very simple. Effect.Morphbgpos is a modified version of Effect.Morph that anticipates having to handle two sets of pixel values. It reads the current states into x and y variables, manipulates them and writes out the appropriate CSS, repeating until the final state is reached.

Handling Other Effect.Morph CSS properties

The extension will pass any CSS that isn’t a background-position property to a new instance of Effect.Morph.

You should be able to replace all Effect.Morph calls with Effect.Morphbgpos, and then simply find+replace them when this functionality becomes available in a future version of the framework.

Limitations

This first version only handles explicit background-position statements, using pixel values, and duration is the only supported option.

As it’s only extending Script.aculo.us by a fraction it seems to be robust across the browsers I’ve tested.

Download & usage

Download the js file here (or here as text). Use just as you would Effect.Morph by settings CSS property-value pairs, and a duration.

Practical Archaeological Excavation Techniques, day five

#134

Morning, Sunday 2nd November. Weather: cold, but sunny.

Read the rest of this entry »

Practical Archaeological Excavation Techniques, day four

#133

Day Four, afternoon of 31st October 2008.

Recording of a trench section on context recording sheets, and some interpretation. Read the rest of this entry »

RSS take-up peaks at 11pc

#132

I won’t be spending $279 to find out the details:

Nearly half of interactive marketers use RSS, but consumer adoption has only reached 11%. Of the consumers who haven’t adopted RSS, most don’t understand how RSS is relevant to their lives and the way they seek information. If marketers expect to reach a critical mass of consumers by using content syndication, then they must take on the burden of education.

[source: forrester.com...150,00.html]

So I wonder how many people knew they were using RSS, and how many accessed syndicated material without realising the nature of it’s origin. Yahoo Pipes for instance, mashups etc.

Were Podcasts included or excluded?

Practical Archaeological Excavation Techniques, day three

#131

My third day on site for the Archaeological Excavation Techniques course.

Afternoon of Saturday18th October 2008. Weather -A sunny afternoon that turned wet and windy.

Today I was to build on the reading I’d done from Philip Barker’s book and the Liverpool Museums site recording guide and begin to put the theory into practice.

I was allocated an area of a trench to examine and record appropriately on context sheets. The sheets form detailed textual descriptions of the contexts (a layer of sand for example, or feature within it) apparent in a trench along with descriptive diagrams.

Today I learned of a new importance for the balks between trenches. In addition to providing safe access (for excavator and the archaeology) across the site, leaving a near complete depth of the trench undisturbed allows features not previously noted (for example, if the weather or daylight precluded them from notice) to remain and be recorded.

In this instance, the trench section had some intrigue – beneath a layer of sandy soil already recorded, lay a circular section of small and larger stones, finer gravels within, surrounded by grey sand. Beneath this, the section had areas of orangey iron panning. These and other features of the trench lead us to believe this is a (Mediæval) ditch – the stones seem to form a line across the site indicating they were posited to allow water flow. The gravels and iron deposits beneath, add to the notion that water once flowed along the lines of stones.

My job was to record in detail on the context sheets a description of each context ( the circular stoney area and its surroundings, and the iron layer beneath). On a third sheet, the ‘cut’ of the section – the perceived edges of the ditch as they’d been originally cut – was to be recorded, although it was thought that this would be done on another day as the feature was difficult to discern.

Before that I had to clean up the section, removing areas that had been slightly weathered by rain by careful removal of material to give a crisp edge that reveals the colour of the earth and aids identification of the different contexts.

The little cleaning I did revealed a second small cluster of gravel adjacent to the larger cluster of stones and an upward curve in the underlying layer that could influence a decision on where the cut of the ditch might lie.

The finer details of the section are difficult to see and require some adjustment of the eye to discern. For this reason repeated discussion of what is apparent in the section can help to determine what features are present. The clear layering of the contexts was disturbed only by runs of light grey sand which are thought to be evidence of animal burrowing. Nevertheless care must be taken to ensure that what the eye sees is not recorded without thought.

The supervisor showed me a drawing of the section I was to further record. These use a 1-to-10 ratio of measurement as opposed to the 1-to-20 ratio used on plan drawings. Recorded in the section drawing were the outlines of the contexts I was to further examine along with outlines for the larger rock features. As with every other aspect of the site, sections have unique numbers of their own for later cross-reference with site, trench, context and find numbers. The drawings also record their orientation so a section may be recorded for all sides of a trench.

I also learned today that another numbering scheme exists for excavation – view numbers – numbers (preceded by a letter ‘V’) given to photographed areas. These are (as ever) retrieved sequentially from pre-printed sheets as required and written on a small blackboard placed in shot.

The recording reference manual contains guidance on the format of all the information that needs to be recorded in each section of the context sheet. The methods range from the ordered to the anecdotal in order to allow as many facets of the context to be recorded, but also allow for quick understanding later on. For example to describe a cut a recorder details a numbered list of predefined features:

  1. Shape in plan
  2. Shape in Section
  3. Dimensions

For a section, these elements are denoted by letters:

  1. Consistency
  2. Texture
  3. Colour
Munsell soil chart  - www.dgcolour.co.uk
An example Munsell Soil Colour chart from dgcolour.co.uk

I was also introduced to Munsell soil colour charts today. A flipbook of punched card pages with printed colour indicators of different soil colours. Each lozenge of colour is bounded by punched holes so that a sample of earth may be dampened and placed on a finger or trowel beneath the page in order to match it to a colour. On the facing page to these punched pages are divided spaces that show the chroma and value definitions (for example 5/4, along with a brief description such as ‘weak red’) for the sample which may then be recorded on the context sheets. Each page has it’s own identifier too – for example 10 YR for a degree of Yellow-Red.

Sadly the weather changed for the worse before I could begin recording and the day’s work was drawn to a premature close.

Before leaving the site I walked towards the farm where the site owners are constructing what will probably be the only Iron Age roundhouses you’ll find (standing!) in this region.

The first is being built to the same dimensions as the roundhouse found in the same field in previous excavations, and will be one of six arranged for the purpose of providing an educative environment for this under-examined period in the North West’s history.

Practical Archaeological Excavation Techniques, day two

#130

An account of my second day on the Archaeological Excavation Techniques course run by Liverpool University Continuing Education in conjunction with National Museums Liverpool.

Monday 13th October 2008. Weather – Morning overcast, cold. sunnier in the afternoon, wind speed increased.

Read the rest of this entry »

Practical Archaeological Excavation Techniques, day one

#129

An account of the first day on the Archaeological Excavation Techniques course run by Liverpool University Continuing Education in conjunction with National Museums Liverpool.

Monday 6th October 2008. Weather – Morning sunny with a light mist visible over distance. Overcast in the afternoon.

Read the rest of this entry »

Peter Ellis’ other build

#128

Picture of Sixteen Cook Street, LiverpoolPicture of Sixteen Cook Street, Liverpool
View of Sixteen Cook Street, Liverpool

Peter Ellis’ other build, 16 Cook Street Liverpool.