Skip to content

Commit

Permalink
Ready added
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseba Juániz committed Sep 21, 2015
1 parent e23f3c8 commit e073f6b
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 12 deletions.
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Yii2 Blade Layout

Routing and filtering extension system for Yii2 framework that emulates the Laravel routing system.
Blade layout extension system for Yii2 framework.

## What's Yii2 Blade Layout?

This module changes the route system definition of Yii2 in order to, instead of having to define the routes in the config file of the application now will be possible to make a series of files that hold the routes that the user will define for his web. This module lets the calling to a series of methods that will define the system routes in a more intuitive way that the basic Yii2 system getting it's inspiration from the routing system defined by Laravel.
This module adds support to Blade Layout system in your Yii2 app installation.

Developed by Joseba Juániz ([@Patroklo](http://twitter.com/Patroklo))

Expand All @@ -14,11 +14,6 @@ Developed by Joseba Juániz ([@Patroklo](http://twitter.com/Patroklo))

* Yii2

## Future plans

* Pass manual parameters to the filters.
* Automatic system to make RESTFul Routes.

## License

This is free software. It is released under the terms of the following BSD License.
Expand Down Expand Up @@ -55,7 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Install package via [composer](http://getcomposer.org/download/) `"cyneek/yii2-blade": "*"`
* Update config file _'config/web.php'_

```
```php

...
'components' => [
Expand All @@ -71,13 +66,35 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]
...
```


* Make a _blade_cache_ directory in your @runtime directory writable by the web user.
* Profit!

## Parameters

* *cachePath* [String/Required] Directory where Blade Layout system will store the view files once they are treated.
* viewPaths [String[]/Optional] Array holding a list of directories where views and layouts will be stored.
* extension [String/Optional] It you are going to use another extension than `.blade` for your views it should be stated here.
* **cachePath** [String/Required] Directory where Blade Layout system will store the view files once they are treated. Should be writable by the web server user (for example www-data).
* **viewPaths** [String[]/Optional] Array holding a list of directories where views and layouts will be stored. This is not really necessary since the system will get the view paths once they are retrieved to the Blade Wrapper.
* **extension** [String/Optional] It you are going to use another extension than `.blade` for your view files, it should be stated here as well as in the array key of the renderers array.

### Using the `layout` parameter

It's possible to define the controller's parameter `layout` with a Blade file. But since the Yii2 view render system it's not 100% compatible with the Blade Layout rendering, you'll have to add a behavior to that controller called `BladeBehavior` that will integrate both systems.

To add this behavior you'll only have to include:


```php
public function behaviors()
{
return [
...
'blade' => [
'class' => BladeBehavior::className()
],
...
];
}
```

### Basic use
Then the layout view file will be rendered before the views if both layout and view files have a blade file extension. If not, Yii2 normal rendering system will be used instead.
101 changes: 101 additions & 0 deletions README_spanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Yii2 Blade Layout

Extensión de Blade para el framework Yii2.

## ¿Qué es Yii2 Blade Layout?

Este módulo añade soporte al sistema de Blade Layout en nuestra aplicación de Yii2.

Desarrollado by Joseba Juániz ([@Patroklo](http://twitter.com/Patroklo))

[English Readme version](https://github.com/Patroklo/yii2-blade/blob/master/README.md)

## Minimum requirements

* Yii2


## Licencia

Esto es software libre. Está liberado bajo los términos de la siguiente licencia BSD

Copyright (c) 2014, by Cyneek
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of Cyneek nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


## Instalación

* Instalar [Yii 2](http://www.yiiframework.com/download)
* Instalar el paque vía [composer](http://getcomposer.org/download/) `"cyneek/yii2-blade": "*"`
* Modificar el fichero config _'config/web.php'_

```php

...
'components' => [
'view' => [
'class' => 'yii\web\View',
'renderers' => [
'blade' => [
'class' => '\cyneek\yii2\blade\ViewRenderer',
'cachePath' => '@runtime/blade_cache',
],
],
],
]
...
```


* Crear un directorio llamado _blade_cache_ en la raíz de @runtime que pueda ser editado por el usuario web.
* Profit!

## Parameters

* **cachePath** [String/Obligatorio] Directorio donde el sistema Blade almacenará las vistas una vez han sido tratads. Tiene que ser editable por el usuario web (por ejemplo www-data).
* **viewPaths** [String[]/Opcional] Array con una lista de directorios donde las vistas y layouts residen. No es necesario realmente ya que el sistema obtiene los directorios de las propias vistas y layouts y se añaden automáticamente al Wrapper de Blade.
* **extension** [String/Opcional] Si vas a usar una extensión para las vistas diferente de `.blade`, debería estar aquí también definido además de en el key del array `renderers`.

### Usando el parámetro `layout`

Es posible definir en el parámetro `layout` de los controllers un fichero de tipo Blade. Pero ya que el sistema de renderizado de vistas de Yii2 no es 100% compatible con el de Blade, tendrás que añadir un behavior al controller llamado `BladeBehavior` que se encargará de integrar ambos sistemas.

Para añadir este behavior tan sólo hay que incluir en el controller:

```php
public function behaviors()
{
return [
...
'blade' => [
'class' => BladeBehavior::className()
],
...
];
}
```

Entonces el fichero layout será renderizado antes que las vistas que contiene, a diferencia del sistema estandar de Yii2, que las renderiza al final.

0 comments on commit e073f6b

Please sign in to comment.