Escolar Documentos
Profissional Documentos
Cultura Documentos
INSTALACIN:
Composer:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Symfony
composer create-project symfony/framework-standard-edition path/
"2.5.*"
PERMISOS:
setfacl -R -m u:usuario1:rwx -m u:usuario2:rwx app/cache app/logs
setfacl -dR -m u:usuario1:rwx -m u:usuario2:rwx app/cache app/logs
ACCESO:
Editar fichero: web/config.php
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1','192.168.1.35',
'::1',
)))
Editar fichero: web/app_dev.php
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1',
'192.168.1.35', 'fe80::1', '::1')) || php_sapi_name() === 'cliserver')
)
PREVIO
Extension: INTL
Instalar librera ICU
yum install libicu-devel
compilar la extensin en el directorio del cdigo fuente php
cd /usr/src/php-5.5.15/ext/intl
phpize
./configure
make
make install
Agregamos la extensin intl.so a nuestro archivo php.ini
Extensin=intl.so
NOTAS
Agregar enlaces simblicos a los bundles de tu proyecto (valido en
servidor Linux)
php app/console assets:install --symlink
de desarrollo
cache:clear --no-warmup --env=dev
de produccin
cache:clear --no-warmup --env=prod
Generando Bundle
Comando de consola que genera el esqueleto completo de un bundle con
slo contestar a varias preguntas bsicas.
$ php app/console generate:bundle
Bundle namespace: Respuesta: Cupon/OfertaBundle
Bundle name: OfertaBundle
Target directory: ENTER
Configuration format: YML
Do you want to generate the whole directory structure: NO
Creando Entidades
Para aadir los getters y setters para todas las propiedades.
$ php app/console generate:doctrine:entities SatBundle
Para generar automticamente entidades completas
$ php app/console doctrine:generate:entity
shortcut name: SatBundle:Ciudad
Configuration format (yml, xml, php, or annotation) [annotation]:
<Enter>
Aadimos los campos
Do you want to generate an empty repository class [no]? No
Do you confirm generation [yes]? Yes
Creando la BD
Para crear la BD especificada se usa:
$ php app/console doctrine:database:create
$ php app/console doctrine:database:create --connection=user_oti
new
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBu
ndle(),
);
// ...
}
}
Cargar datos mediante Fixtures
Para cargar los datos en la aplicacin, simplemente ejecuta el siguiente
comando:
$ php app/console doctrine:fixtures:load
> purging database
> loading Cupon\CiudadBundle\DataFixtures\ORM\ciudades
Para hacer que se inicialicen, aade la opcin --purge-with-truncate
$ php app/console doctrine:fixtures:load --purge-with-truncate
Para no borrar los datos existente, puedes emplear la opcin --append, que
hace que los nuevos datos se aadan a los ya existentes
$ php app/console doctrine:fixtures:load --append
Modificar estructura de los formularios
Para poder aadir funcionalidad a los formularios en su vista agregamos
esto:
# Twig Configuration
twig:
form:
resources:
- 'SatBundle:Form:fields.html.twig'
ERRORES:
No actualiza CSS ni JS
Se debe reactualizar los assets con el comando.
$ php app/console assets:install --symlink
Accesar a los entity manager en multiple conecciones
// All three return the "default" entity manager
$em = $this->get('doctrine')->getManager();
$em = $this->get('doctrine')->getManager('default');
$em = $this->get('doctrine.orm.default_entity_manager');
// Both of these return the "user_oti" entity manager
$customerEm = $this->get('doctrine')->getManager('user_oti');
$customerEm = $this->get('doctrine.orm.user_oti_entity_manager');
Llamar a los repositorios
// Retrieves a repository managed by the "default" em
$products = $this->get('doctrine')
->getRepository('AcmeStoreBundle:Product')
->findAll()
;