You must first sign up to be able to contribute.

Version 12 (modified by fabien, 9 years ago)

WARNING: This page is very old and deprecated. Symfony is now bundled with its own rock-solid YAML parser and dumper, so using syck is NOT recommended. As far as performance is concerned, it is a non-issue as all YAML files are cached as PHP files during the very first request in the production environment.

Installing & Using Syck (a PHP extension for swiftly parsing YAML)

About syck

Before Symfony 0.6, YAML parsing was handled solely by a PHP library called "spyc", which is a very tolerant but slow language parser because it is, after all, written in PHP. Those of you experiencing serious delays in the development environment may not know but it is most likely spyc to blame. The solution is using syck, a PHP extension written in C and predecessor to spyc. In general, to parse your routing.yml or settings.yml you'll see a speed difference of about 1000ms vs 1ms -- when you have both installed you can benchmark them easily.

Thankfully, symfony will use syck by default if its function exists, syck_load(), and your speed improvements will happen transparently (see The problem you'll encounter will be installing syck, but we have some tips and tricks to get around those hurdles.

Don't worry -- installing syck still only takes a few minutes to get it running.

Installing from a source release

1. Requirements for syck

To compile syck from its release, you require:

  • autoconf
  • automake
  • yacc
  • the PHP5 include headers (for the PHP extension)

At the time of writing, it has been compiled successfully on Mac OS X 10.4, Linux 2.4 and FreeBSD.

2. Downloading the latest release

The latest release is syck-0.55. You can grab it from the syck home page at

The current location (Mar-2006) is

Once you have your tarball source, you should unpack it:

tar zxvf syck-0.55.tar.gz
cd syck-0.55

3. Compiling & Installing libsyck

Before you can create your PHP extension, you need to compile and install the shared C library called libsyck. It is used universally by all the extensions of syck, such as Ruby, Python, PHP and Cocoa (OCaml).

make check
sudo make install

This should all work without a problem.

4. Compiling & Installing syck for PHP

Pre-Requirement : You need to have autoconf installed

If you have PECL infrastructure installed, installation of syck is trivial:

pecl install syck-beta

Otherwise, download latest extension from here

tar xzf syck-0.9.2.tgz
cd syck-0.9.2
make install

5. Loading the extension

This is the easiest part. Open your php.ini configuration file in your favourite editor and at the bottom of the file (or wherever you like), add this line:

Note: If this is the first extension you are installing, check your extension_dir setting in php.ini. It should be pointing to the directory where resides.

6. Testing syck

You can test your syck PHP extension with the PHP command:

php -r 'print_r(syck_load("requirements: { something: 1 }"));'

You should receive this as a result:

    [requirements] => Array
            [something] => 1


Remember: Apache and PHP error logs are your friend. Check them frequently during this process for any hints.

7. Symfony adjustments

There is, actually, one 'bug' in symfony's sfYaml.class.php which needs to be fixed. sfYaml expects Spyc->load() and syck_load() to return an empty array in the event that there is no YAML to parse, but this is not the case. syck_load returns an unknown type (null). You will get errors in symfony because of this, but that is good: it means syck is working.

For more information about this adjustment, look at

Also, to be certain that you are running syck (like the speed difference isn't a good enough indicator), mabs29 has made a tiny addition to web_debug so that you can see your memory usage and whether you have the syck extension. The patch is here:

8. syck-0.55 quirks

The latest stable release, 0.55, has some annoying quirks. One such quirk you may encounter is that syck does not parse inline YAML with nested braces properly, such as this:

requirements: { id: ^\d{4}$, key: ^\d{40}$ }

To solve this particular problem, you can either change your inline YAML to fully expanded YAML:

  id: ^\d{4}$
  key: ^\d{40}$

Or you can attempt installing syck from SVN source.

Installing syck from SVN

Installing from the SVN source is much less likely to work, not least of all because it is not considered stable. There are certain incompatibilities which are not so easy to fix or haven't had a fix found for them yet.

This wiki was written using syck @ revision 231. Unless stated otherwise, the directions for compiling from SVN are the same as compiling from a release.

1. Requirements

In addition to the requirements stated above, you also need re2c:

2. Downloading from SVN

You can checkout the latest revision of syck from the developer's new SVN repository:

svn co syck-r231

3. Compiling & installing libsyck

cd syck-r231
sh bootstrap
make check
sudo make install

If you have an error about sycklex, most likely you need to comment out this line in lib/syck.h (line 249):

int sycklex( union YYSTYPE *, SyckParser * );

However, there are some other errors which haven't had a fix found yet. Here's an example of one being worked on currently to no avail:

Should you find a solution to your errors, please post a comment to the wiki and it will be integrated into this section.

4. Compiling & Installing syck for PHP

See instructions above

5. Symfony adjustments

You still need to fix sfYaml.

6. syck-0.60

No quirks found as of yet.

Installing syck from PECL

Since 10 July 2007 syck is also a PECL package; this will make more easy to install this PHP extension on your system.

1. Requirements

The requirements are the same as for compiling from source, and also you need to install libsyck developement headers, either from your distribution, or from source as above.

2. Download, compiling & installing

You have to issue this single line command from a privileged user (e.g. root) to successfully complete the task. At the time of writing, the latest version available is 0.9.2

pecl install channel://

3. Loading the extension

See instructions above

4. syck-0.9.2

No quirks found as of yet.


Thanks to benoitm, mabs29, RoVeRT and the #symfony IRC channel on