GithubHelp home page GithubHelp logo

johantell / kohana-yaml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gevans/kohana-yaml

0.0 0.0 0.0 136 KB

YAML config, i18n, and library for Kohana 3.x

Home Page: https://github.com/gevans/kohana-yaml

License: MIT License

PHP 100.00%

kohana-yaml's Introduction

Kohana 3.x YAML Module

YAML stands for YAML Ain't a Markup Language. Enjoy easy to understand syntax even your boss will be able to read and write! This module will let you write your Kohana config and i18n files in YAML.

Installation

Clone the repository (or add it as a submodule) to your modules directory:

$ git clone git://github.com/gevans/kohana-yaml.git modules/yaml

Update & initiate submodules (to get the latest Symfony YAML libraries):

$ cd modules/yaml
$ git submodule update --init

Enable the module in your bootstrap.php:

<?php
Kohana::modules(array(
    'yaml' => MODPATH.'yaml', // YAML config & i18n reader
    // ...
));

Optionally, you can compile php-yaml.

General Usage

Configuration

You can write your config files in YAML like so:

# This is a comment
some_key: some_value
group:
  # Don't forget the PHP_EOL or PHP will mess you *and* the line breaks up:
  dynamic_key: <?= 'PHP!'.PHP_EOL ?>
  another_key: another_value

Save the files as config/<filename>.yml and Kohana will be able to read them as usual.

I18n

I18n is just as easy as the last part was. Just save your .yml files in the i18n/ while the module does that rest. For example:

# i18n/es.yml
"Hola, :name!": "Hello, :name!"
Yo no hablo Español.: I don't speak Spanish.
Wait. What?: Espere. ¿Qué?

After that, using __('Yo no hablo Español.') returns I don't speak Spanish. Having fun yet?

You can read The Official YAML Web Site for more advanced syntax.

Optionally, install YAML extension (*nix only)

You can enjoy better performance and faster YAML parsing by installing the native YAML extension.

Ubuntu

On Ubuntu, install some packages to build the extension:

$ sudo apt-get install build-essential php5-dev libyaml-dev

Then, use PECL to install the extension:

$ sudo pecl install channel://pecl.php.net/yaml-1.0.1

You'll need to enable the newly installed extension. On Ubuntu, you can do so by creating a new file called /etc/php5/conf.d/yaml.ini or adding to your php.ini:

; configuration for YAML extension
extension=yaml.so

Save the file, restart your web server, and you should be good to go!

Mac OSX

Using Homebrew, you can install the YAML extension from @josegonzalez's homebrew-php repository:

$ brew install https://raw.github.com/josegonzalez/homebrew-php/master/Formula/yaml-php.rb
######################################################################## 100.0%
==> Downloading http://pecl.php.net/get/yaml-1.0.1.tgz
==> phpize
==> ./configure --prefix=/usr/local/Cellar/yaml-php/1.0.1
==> make
==> Caveats
To finish installing yaml-php:
  * Add the following line to /usr/local/etc/php.ini:
    extension="/usr/local/Cellar/yaml-php/1.0.1/yaml.so"
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the yaml module.
  * If you see it, you have been successful!
==> Summary
/usr/local/Cellar/yaml-php/1.0.1: 4 files, 76K, built in 4 seconds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.