Siguelas y cambia las partes de username y demas para tu propio proyecto.
$ mkdir blog
$ cd blog
symfony init-project blog
$symfony init-app frontend
vi config/schema.yml
propel:
weblog_post:
_attributes: { phpName: Post }
id:
title: varchar(255)
excerpt: longvarchar
body: longvarchar
created_at:
weblog_comment:
_attributes: { phpName: Comment }
id:
post_id:
author: varchar(255)
email: varchar(255)
body: longvarchar
created_at:
$ vi config/database.yml
all:
propel:
class: sfPropelDatabase
param:
dsn: mysql://username:password@localhost/databasename
propel.database.createUrl = mysql://username:password@localhost/ propel.database.url = mysql://username:password@localhost/databasename
$ symfony propel-build-model
$ symfony propel-build-sql
$ symfony propel-insert-sql
$ symfony propel-generate-crud frontend post Post $ symfony propel-generate-crud frontend comment Comment $ symfony clear-cache
$ mv web/.htaccess web/.htaccess.bak
http://localhost/~tuusername/blog/web
http://localhost/~turusername/blog/web/frontend_dev.php/post
$ vi apps/frontend/templates/layout.php
<div id="container" style="width:600px;margin:0 auto;border:1px solid grey;padding:10px">
<div id="navigation" style="display:inline;float:right">
<ul>
<li><?php echo link_to('Lista de posts', 'post/list') ?></li>
<li><?php echo link_to('Lista de comentarios', 'comment/list') ?></li>
</ul>
</div>
<div id="title">
<h1><?php echo link_to('Mi primer proyecto en Symfony', '@homepage') ?></h1>
</div>
<div id="content" style="clear:right">
<?php echo $sf_data->getRaw('sf_content') ?>
</div>
</div>
ln -s /usr/share/php/data/symfony/web/sf /home/lyama/public_html/blog/web/sf
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
#
# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /~lyama/blog/web/
#
# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule .* - [L]
#
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
#
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
#
# big crash from our front web controller
ErrorDocument 500 "<h2>Application error</h2>symfony application failed to start properly"
$ vi apps/frontend/config/view.yml
metas: title: Mi Chidisimo Blog en Symfony robots: index, follow description: symfony project keywords: symfony, project language: en
$ symfony init-module frontend main
$ vi apps/frontend/modules/main/actions/actions.class.php
public function executeIndex()
{
}
<h1>Bienvenido al blog de Leonardo</h1> <p>Eres el visitante numero <?php echo rand(1000,5000) ?> de este dia.</p>
homepage:
url: /
param: { module: main, action: index }
$ symfony cc
$ vi apps/frontend/modules/post/actions/actions.class.php
$c = new Criteria();
$c->add(CommentPeer::POST_ID, $this->getRequestParameter('id'));
$c->addAscendingOrderByColumn(CommentPeer::CREATED_AT);
$this->comments = CommentPeer::doSelect($c);
$ vi apps/frontend/modules/post/templates/showSuccess.php
$ vi apps/frontend/modules/post/templates/showSuccess.php
...
<?php use_helper('Text', 'Date') ?>
<hr />
<?php if ($comments) : ?>
<p><?php echo count($comments) ?> comment<?php if (count($comments) > 1) : ?>s<?php endif; ?> to this post.</p>
<?php foreach ($comments as $comment): ?>
<p><em>posted by <?php echo $comment->getAuthor() ?> on <?php echo format_date($comment->getCreatedAt()) ?></em></p>
<div class="comment" style="margin-bottom:10px;">
<?php echo simple_format_text($comment->getBody()) ?>
</div>
<?php endforeach; ?>
<?php endif; ?>