Documente Academic
Documente Profesional
Documente Cultură
Ir a Mi PC -> propiedades del sistema -> Opciones avanzadas -> variables de entorno
y buscar Path y agregarle las rutas de la carpeta php de Xampp y donde dejamos el
FM/bin (en este caso todo se instalo en una carpeta c:\web\zend)separado por punto y
coma (;) y se recomienda reiniciar.
Para comprobar la instalación abrir la consola (CMD) y escribir:
zf show version
Para comprobar q nuestra instalacion este OK, crear un host virtual, agregando al
archivo httpd.conf que se encuentra en C:\xampp\apache\conf, las siguientes líneas:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ blog/index.php [NC,L]
zf create db-table.from-database
application/models/DbTable/posts.php
<?php
class Application_Model_DbTable_Posts extends
Zend_Db_Table_Abstract
{
protected $_name = 'posts';
}
Index: http://localhost/blog/post/index
Add: http://localhost/blog/post/add
Edit: http://localhost/blog/post/edit
Del: http://localhost/blog/post/del
Nota: dependiendo del xampp instalado hay que tocar algunos archivos, para que
pueda verse en el navegador:
en "xampp\apache\bin"
copiar libmysql_5.0.51a.dll libmysql.dll
en "xampp\php"
copiar libmysql_5.0.51a.dll libmysql.dll
en "xampp\php\ext"
copiar php_mysql_5.0.51a.dll php_mysql.dll
copiar php_mysqli_5.0.51a.dll php_mysqli.dll
Reiniciar xammp
- Crear layout
Layout es la parte de la vista que se repite en todas las páginas. Head,
Estilos, etc…
views/script/post/Index.phtml
<p><a href="<?php echo $this->url(array('controller'=>'post','action'=>'add'));?>">
Nuevo post</a></p>
<table>
<tr><th>Titulo</th><th>Descripción</th><th> </th>
</tr>
<?php
foreach ( $this->posts as $post ) :
?>
<tr><td><?php echo $this->escape ( $post->Titulo );?></td>
<td><?php echo $this->escape ( $post->Descripcion );?></td>
<td><a href="<?php echo $this->url ( array ('controller' => 'post', 'action' => 'edit',
'id' => $post->id ) );?>">Edit</a>
<a href="<?php echo $this->url ( array ('controller' => 'post', 'action' => 'del', 'id' =>
$post->id ) ); ?>">Del</a></td>
</tr>
<?php endforeach;?>
</table>