root@my-ubuntu:/var/www/symfony# php app/console sonata:page:create-site
Please define a value for Site.name : ASF Network
Please define a value for Site.host : symfony
Please define a value for Site.relativePath : /
Please define a value for Site.enabled : true
Please define a value for Site.enabledFrom : now
Please define a value for Site.enabledTo : +100 years
Please define a value for Site.default : true
Please define a value for Site.locale : -
Creating website with the following information :
name : ASF Network
site : http(s)://symfony
enabled : Thu, 15 Aug 2013 17:37:14 +0800 => Tue, 15 Aug 2113 17:37:14 +0800
Confirm site creation ?y
Site created !
You can now create the related pages and snapshots by running the followings commands:
php app/console sonata:page:update-core-routes --site=4
php app/console sonata:page:create-snapshots --site=4
root@my-ubuntu:/var/www/symfony#
Thursday, August 15, 2013
Monday, August 12, 2013
Sonata Admin Installation for symfony 2.2
OPTION 1
# composer.json
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.2.*",
"symfony/monolog-bundle": "2.2.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/framework-extra-bundle": "2.2.*",
"sensio/generator-bundle": "2.3.*",
"jms/security-extra-bundle": "1.4.*",
"jms/di-extra-bundle": "1.3.*",
"doctrine/data-fixtures": "*",
"doctrine/doctrine-fixtures-bundle": "*",
"friendsofsymfony/user-bundle": "*",
"knplabs/knp-paginator-bundle": "*",
"payum/payum-bundle": "*",
"payum/paypal-express-checkout-nvp": "*",
"doctrine/doctrine-migrations-bundle": "dev-master",
"doctrine/migrations": "dev-master",
"symfony/console": "2.2.*@dev",
"sonata-project/admin-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"sonata-project/intl-bundle": "2.1.*",
"sonata-project/cache-bundle": "2.*",
"sonata-project/block-bundle": "2.2.*@dev",
"simplethings/entity-audit-bundle": "dev-master",
"knplabs/knp-menu-bundle":"1.1.x-dev"
# app/AutoLoad
# app/AppKernel
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
// new Acme\HelloBundle\AcmeHelloBundle(),
new ASF\PembedaBundle\ASFPembedaBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
// new Payum\Bundle\PayumBundle\PayumBundle(),
// new Blogger\BlogBundle\BloggerBlogBundle(),
// new Doctrine\Bundle\DoctrineMigrationsBundle\DoctrineMigrationsBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
install the assets from the bundles: php app/console assets:install web
delete your cache: php app/console cache:clear
OPTION 2
1. Download Symfony 2.2 package
2. Check version : php app/console -V
3. Install require bundles :
11. app/config/config.yml
# app/config/config.yml
# FOS user bundle configuration
fos_user:
db_driver: orm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
12. Generate & configure User bundle :
# app/config/config.yml
doctrine:
dbal:
#for SonataNotificationBundle
types:
json: Sonata\Doctrine\Types\JsonType
#----
14 - Add sonata admin configuration :
#app/config/config.yml
sonata_admin:
title: <your application title>
title_logo: /path/to/logo.png
dashboard:
blocks:
# # display a dashboard block
- { position: left, type: sonata.admin.block.admin_list }
15 - Create super admin user :
# composer.json
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.2.*",
"symfony/monolog-bundle": "2.2.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/framework-extra-bundle": "2.2.*",
"sensio/generator-bundle": "2.3.*",
"jms/security-extra-bundle": "1.4.*",
"jms/di-extra-bundle": "1.3.*",
"doctrine/data-fixtures": "*",
"doctrine/doctrine-fixtures-bundle": "*",
"friendsofsymfony/user-bundle": "*",
"knplabs/knp-paginator-bundle": "*",
"payum/payum-bundle": "*",
"payum/paypal-express-checkout-nvp": "*",
"doctrine/doctrine-migrations-bundle": "dev-master",
"doctrine/migrations": "dev-master",
"symfony/console": "2.2.*@dev",
"sonata-project/admin-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"sonata-project/intl-bundle": "2.1.*",
"sonata-project/cache-bundle": "2.*",
"sonata-project/block-bundle": "2.2.*@dev",
"simplethings/entity-audit-bundle": "dev-master",
"knplabs/knp-menu-bundle":"1.1.x-dev"
# app/AutoLoad
# app/AppKernel
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
// new Acme\HelloBundle\AcmeHelloBundle(),
new ASF\PembedaBundle\ASFPembedaBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
// new Payum\Bundle\PayumBundle\PayumBundle(),
// new Blogger\BlogBundle\BloggerBlogBundle(),
// new Doctrine\Bundle\DoctrineMigrationsBundle\DoctrineMigrationsBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
# app/config/config.yml sonata_block: default_contexts: [cms] blocks: sonata.admin.block.admin_list: contexts: [admin] sonata.block.service.text: ~ sonata.block.service.rss: ~
# app/config/config.yml
install the assets from the bundles: php app/console assets:install web
delete your cache: php app/console cache:clear
OPTION 2
1. Download Symfony 2.2 package
2. Check version : php app/console -V
3. Install require bundles :
php composer.phar require sonata-project/block-bundle:2.2.3
php composer.phar require sonata-project/jquery-bundle:1.8.0
php composer.phar require knplabs/knp-menu:1.1.2
php composer.phar require knplabs/knp-menu-bundle:1.1.2
php composer.phar require sonata-project/exporter:1.3.0
php composer.phar require sonata-project/admin-bundle:2.2.2
php composer.phar require sonata-project/doctrine-orm-admin-bundle:2.2.*@dev
php composer.phar require sonata-project/intl-bundle:2.1.*
4. Alter your config.yml and add following configurations
# app/config/config.yml
# Sonata block Configuration
sonata_block:
default_contexts: [cms]
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
#sonata.admin_doctrine_orm.block.audit:
# contexts: [admin]
sonata.block.service.text:
sonata.block.service.rss:
# knp menu configuration (optional)
knp_menu:
twig:
template: knp_menu.html.twig
templating: false
default_renderer: twig
# Translator configuration
framework:
translator: ~
# Sonata intl configuration
sonata_intl:
timezone:
# default timezone used as fallback
default: Europe/Paris
# locale specific overrides
locales:
fr: Europe/Paris
en_UK: Europe/London
5. AppKernel.php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Sonata\BlockBundle\SonataBlockBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\IntlBundle\SonataIntlBundle(),
// ...
);
}
6. Install the assets from the bundles
php app/console assets:install web
7. app/config/routing.yml
# app/config/routing.yml
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
8. Delete cache files : php app/console cache:clear
9. Install FOS & sonata-project/user-bundle
php composer.phar require friendsofsymfony/user-bundle:1.3.2
php composer.phar require sonata-project/user-bundle:2.1.1
10 . app/AppKernel.php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Sonata\BlockBundle\SonataBlockBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\IntlBundle\SonataIntlBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'),
new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
// ...
);
}
11. app/config/config.yml
# app/config/config.yml
# FOS user bundle configuration
fos_user:
db_driver: orm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
12. Generate & configure User bundle :
php app/console sonata:easy-extends:generate SonataUserBundle
add to autoload.php : $loader->add('Application', __DIR__);
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
/**
* @var $loader ClassLoader
*/
$loader = require __DIR__.'/../vendor/autoload.php';
// intl
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
}
$loader->add('Application', __DIR__);
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;
NOTE : if symfony give 'Unknown column type "json" requested.......' error, add custom type in Doctrine configuration, see below codeRegister User bundle in app/AppKernel.php : new Application\Sonata\UserBundle\ApplicationSonataUserBundle()// app/AppKernel.php public function registerBundles() { return array( // ... new Sonata\BlockBundle\SonataBlockBundle(), new Knp\Bundle\MenuBundle\KnpMenuBundle(), new Sonata\jQueryBundle\SonatajQueryBundle(), new Sonata\AdminBundle\SonataAdminBundle(), new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(), new Sonata\IntlBundle\SonataIntlBundle(), new FOS\UserBundle\FOSUserBundle(), new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'), new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(), new Application\Sonata\UserBundle\ApplicationSonataUserBundle(), // ... ); }Add fos and sonata user routes in app/routing.yml#app/routing.yml fos_user_security: resource: "@FOSUserBundle/Resources/config/routing/security.xml" fos_user_profile: resource: "@FOSUserBundle/Resources/config/routing/profile.xml" prefix: /profile fos_user_register: resource: "@FOSUserBundle/Resources/config/routing/registration.xml" prefix: /register fos_user_resetting: resource: "@FOSUserBundle/Resources/config/routing/resetting.xml" prefix: /resetting fos_user_change_password: resource: "@FOSUserBundle/Resources/config/routing/change_password.xml" prefix: /change-password fos_user_security: resource: "@FOSUserBundle/Resources/config/routing/security.xml" fos_user_profile: resource: "@FOSUserBundle/Resources/config/routing/profile.xml" prefix: /profile fos_user_register: resource: "@FOSUserBundle/Resources/config/routing/registration.xml" prefix: /register fos_user_resetting: resource: "@FOSUserBundle/Resources/config/routing/resetting.xml" prefix: /resetting fos_user_change_password: resource: "@FOSUserBundle/Resources/config/routing/change_password.xml" prefix: /change-password soanata_user: resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml' prefix: /admin sonata_user_impersonating: pattern: / defaults: { _controller: SonataPageBundle:Page:catchAll }clear cache : php app/console cache:clear13. update schema : php app/console doctrine:schema:update --force
# app/config/config.yml
doctrine:
dbal:
#for SonataNotificationBundle
types:
json: Sonata\Doctrine\Types\JsonType
#----
14 - Add sonata admin configuration :
#app/config/config.yml
sonata_admin:
title: <your application title>
title_logo: /path/to/logo.png
dashboard:
blocks:
# # display a dashboard block
- { position: left, type: sonata.admin.block.admin_list }
15 - Create super admin user :
php app/console fos:user:create <username> <email> <password>
access your admin panel using below url
URL : http://yourdomain/app_dev.php/admin/dashboard
16 - Bundles url
https://github.com/sonata-project/SonataBlockBundle
https://github.com/sonata-project/SonatajQueryBundle
https://github.com/KnpLabs/KnpMenu
https://github.com/KnpLabs/KnpMenuBundle
https://github.com/sonata-project/exporter
https://github.com/sonata-project/SonataAdminBundle
https://github.com/sonata-project/SonataDoctrineORMAdminBundle
https://github.com/sonata-project/SonataIntlBundle
Option 3
Tested with Symfony Standard 2.0.7 (http://symfony.com/download?v=Symfony_Standard_Vendors_2.0.7.tgz)
This is basically a merge of the installation-guides of FOSUserBundle (https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md), SonataAdminBundle (http://sonata-project.org/bundles/admin/master/doc/reference/installation.html) and SonataUserBundle (http://sonata-project.org/bundles/user/master/doc/reference/installation.html)
This is basically a merge of the installation-guides of FOSUserBundle (https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md), SonataAdminBundle (http://sonata-project.org/bundles/admin/master/doc/reference/installation.html) and SonataUserBundle (http://sonata-project.org/bundles/user/master/doc/reference/installation.html)
- Add
to your deps file. (Don’t forget the trailing newline.)
[FOSUserBundle]target=bundles/FOS/UserBundle[SonatajQueryBundle]target=/bundles/Sonata/jQueryBundle[SonataAdminBundle]target=/bundles/Sonata/AdminBundle[MenuBundle]target=/bundles/Knp/Bundle/MenuBundle[KnpMenu]target=/knp/menu[SonataUserBundle]target=/bundles/Sonata/UserBundle[SonataEasyExtendsBundle]target=/bundles/Sonata/EasyExtendsBundle[SonataDoctrineORMAdminBundle]target=/bundles/Sonata/DoctrineORMAdminBundle - Run
php bin/vendorsinstall--reinstall - Add the namespaces to app/autoload.php
// app/autoload.php$loader->registerNamespaces(array(// ...'FOS'=> __DIR__.'/../vendor/bundles','Sonata'=> __DIR__.'/../vendor/bundles','Application'=> __DIR__,'Knp'=>array(__DIR__.'/../vendor/bundles',__DIR__.'/../vendor/knp/menu/src',),// ...)); - Enable the bundles in app/AppKernel.php
// app/AppKernel.phppublicfunctionregisterBundles(){$bundles=array(// ...newFOS\UserBundle\FOSUserBundle(),newSonata\jQueryBundle\SonatajQueryBundle(),newSonata\AdminBundle\SonataAdminBundle(),newSonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),newKnp\Bundle\MenuBundle\KnpMenuBundle(),newSonata\UserBundle\SonataUserBundle('FOSUserBundle'),newSonata\EasyExtendsBundle\SonataEasyExtendsBundle(),// ...);// ...} - Add
to app/config/config.yml
# app/config/config.ymlfos_user:db_driver: ormfirewall_name: mainuser_class: Application\Sonata\UserBundle\Entity\User - Run
php app/consolesonata:easy-extends:generate SonataUserBundle - Add the new Bundle to app/AppKernel.php
// app/AppKernel.phppublicfunctionregisterbundles(){$bundles=array(// Application Bundles// ...newApplication\Sonata\UserBundle\ApplicationSonataUserBundle(),// ...);// ...} - Add
to app/config/routing.yml
# app/config/routing.ymlfos_user_security:resource: "@FOSUserBundle/Resources/config/routing/security.xml"fos_user_profile:resource: "@FOSUserBundle/Resources/config/routing/profile.xml"prefix: /profilefos_user_register:resource: "@FOSUserBundle/Resources/config/routing/registration.xml"prefix: /registerfos_user_resetting:resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"prefix: /resettingfos_user_change_password:resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"prefix: /change-passwordadmin:resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'prefix: /admin_sonata_admin:resource: .type: sonata_adminprefix: /adminsoanata_user:resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'prefix: /admin - Add the following to app/config/security.yml
# app/config/security.ymlsecurity:encoders:FOS\UserBundle\Model\UserInterface: sha512role_hierarchy:ROLE_ADMIN: ROLE_USERROLE_SUPER_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]SONATA:- ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT # if you are not using acl then this line must be uncommentedproviders:fos_userbundle:id: fos_user.user_managerfirewalls:# -> custom firewall for the admin area of the URLadmin:pattern: /admin(.*)form_login:provider: fos_userbundlelogin_path: /admin/loginuse_forward: falsecheck_path: /admin/login_checkfailure_path: nulllogout:path: /admin/logoutanonymous: true# -> end custom configuration# defaut login area for standard usersmain:pattern: .*form_login:provider: fos_userbundlelogin_path: /loginuse_forward: falsecheck_path: /login_checkfailure_path: nulllogout: trueanonymous: true# ...access_control:# URL of FOSUserBundle which need to be available to anonymous users- { path: ^/_wdt, role: IS_AUTHENTICATED_ANONYMOUSLY }- { path: ^/_profiler, role: IS_AUTHENTICATED_ANONYMOUSLY }- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }# -> custom access control for the admin area of the URL- { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }- { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }- { path: ^/admin/login-check$, role: IS_AUTHENTICATED_ANONYMOUSLY }# -> end- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }# Secured part of the site# This config requires being logged for the whole site and having the admin role for the admin part.# Change these rules to adapt them to your needs- { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }- { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }# ... - Update your DB-Schema. Run
php app/consoledoctrine:schema:update --force - Now, install the assets from the different bundles:
php app/consoleassets:installweb - Clear your cache:
php app/consolecache:clear - You can create an admin-user and a test-user with the following commands.
php app/consolefos:user:create admin admin@example.com password --super-adminphp app/consolefos:user:create testusertest@example.com password - You need to enable your translator in /app/config.yml.
- Create app/Application/Sonata/UserBundle/Recources/translations/SonataUserBundle.en.ymlwith the following content:
# app/Application/Sonata/UserBundle/Recources/translations/SonataUserBundle.en.ymlform:label_username: Usernamelabel_email: Emaillabel_plain_password: Password (Plain)label_groups: Groupslabel_roles: Roleslabel_locked: Lockedlabel_expired: Expiredlabel_enabled: Enabledlabel_credentials_expired: Credentials Expiredlabel_name: Namelist:label_username: Usernamelabel_email: Emaillabel_enabled: Enabledlabel_locked: Lockedlabel_created_at: Created Atlabel_roles: Roleslabel_name: Namefilter:label_username: Usernamelabel_locked: Lockedlabel_email: Emaillabel_id: IDlabel_name: Name
This entry was posted
on Saturday, November 19th, 2011 at 1:34 pm by jorzekowsky and is filed under Symfony2.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Thursday, July 18, 2013
Bundle : AlphaLemon
1. AlphaLemon CMS Sandbox
- Installtion :
source : https://github.com/alphalemon/AlphaLemonCmsSandbox
Installing from the console
- Installtion :
source : https://github.com/alphalemon/AlphaLemonCmsSandbox
Installing from the console
app/console alphalemon:install-cmshttp://localhost/alcms.php/backend/en/index
user : admin
password : admin
Installing using the web interface
app/console assets:install web
http://localhost/app_dev.php/install
http://localhost/alcms.php/backend/en/index
user : admin
password : admin
Running test unit :
phpunit -c app
Sunday, July 14, 2013
Installation Symfony 2.3
Installation Symfony 2.3
1. Download at Symfony.com/download link
2. Untar and Copy to www root :
cd /var/www/symfony
tar zxvf Symfony_standard.2.x.x.tar.gz
cp -r Symfony/* /var/www/symfony
chmod -R 777 app/cache
chmod -R 777 app/logs
3. Check the pakage & configure
http://localhosts/web/config.php
...
http://localhosts/web/app_dev.php
4. or Configure manually
vi app/config/parameters.yml
Installing vendors
standard vendor :
[symfony]
git=http://github.com/symfony/symfony.git
version=v2.0.0
[twig]
git=http://github.com/fabpot/twig.git
version=v1.1.1
[monolog]
git=http://github.com/Seldaek/monolog.git
version=1.0.0
[doctrine]
git=http://github.com/doctrine/doctrine2.git
version=2.1.0
[swiftmailer]
git=http://github.com/swiftmailer/swiftmailer.git
version=v4.1.0
Storing new project in github
git init
git status
vi .gitignore
insert :
/web/bundles/
/app/boostrap*
/app/cache/*
/app/logs/*
/vendor/
/app/config/parameters.ini
/app/config/parameters.yml
git add .
git config --global user.email "kjagro@gmail.com" git config --global user.email "fadabi"
git commit -m "Initial commit of the ASF project"
git add app/config/parameters.yml.dist
git commit -m "Adding a sample parameter file"
Removing demo pages
Bundles
FOSUserBundle - user managment
KnpMenuBundle - really smart menus
DoctrineFixturesBundle
StofDoctrineExtensionsBundle - easy doctrine behavior
AvalancheImagineBundle - image manipulation
KnpPaginatorBundle
1. Download at Symfony.com/download link
2. Untar and Copy to www root :
cd /var/www/symfony
tar zxvf Symfony_standard.2.x.x.tar.gz
cp -r Symfony/* /var/www/symfony
chmod -R 777 app/cache
chmod -R 777 app/logs
3. Check the pakage & configure
http://localhosts/web/config.php
...
http://localhosts/web/app_dev.php
4. or Configure manually
vi app/config/parameters.yml
Installing vendors
standard vendor :
[symfony]
git=http://github.com/symfony/symfony.git
version=v2.0.0
[twig]
git=http://github.com/fabpot/twig.git
version=v1.1.1
[monolog]
git=http://github.com/Seldaek/monolog.git
version=1.0.0
[doctrine]
git=http://github.com/doctrine/doctrine2.git
version=2.1.0
[swiftmailer]
git=http://github.com/swiftmailer/swiftmailer.git
version=v4.1.0
Storing new project in github
git init
git status
vi .gitignore
insert :
/web/bundles/
/app/boostrap*
/app/cache/*
/app/logs/*
/vendor/
/app/config/parameters.ini
/app/config/parameters.yml
git add .
git config --global user.email "kjagro@gmail.com" git config --global user.email "fadabi"
git commit -m "Initial commit of the ASF project"
git add app/config/parameters.yml.dist
git commit -m "Adding a sample parameter file"
Removing demo pages
Bundles
FOSUserBundle - user managment
KnpMenuBundle - really smart menus
DoctrineFixturesBundle
StofDoctrineExtensionsBundle - easy doctrine behavior
AvalancheImagineBundle - image manipulation
KnpPaginatorBundle
Thursday, June 13, 2013
Steps to move Symfony 2 project to hosting?
Steps to move Symfony 2 project to hosting?
Altenative 1
First the httpd.conf file MUST be changed to reference
/sites/dir/website/web directory as the DocumentRoot directory, all
other files such as lib and config must not be accessible over the web.
Altenative 2
- It depends on kind of hosting that you have: if you have SSH console, then you can do it on hosting after step 2, if you haven`t than do it localy: run command 'php app/console cache:clear --env=prod'.
- Suppose you have on you hosting folders youdomain/public_html, so in public_html must be located all web files. So you must upload all from symfony project (folders: app,src,vendors, bin; files: deps, deps.lock), except folder 'web' in folder 'youdomain'. Everuthing from folder 'web' upload to folder public_html.
- Check CHMOD for folders app/cache and app/logs, there should be write access.
- If there is no file .htaccess in public_html, then create it and add such code in it: https://raw.github.com/symfony/symfony-standard/master/web/.htaccess
- Now you should use youdomain.com/index instead of youdomain.com/app_dev.php/index, that you use locally. If site still did not works, you can open file web/config.php and find code where perform check for IP, you find there only ip 127.0.0.1, add your current ip to this list and upload new config on server. Then you can open path yourdomain/config.php and check what`s wrong. If config.php shows that everything ok, but still didn't work, you can enable app_dev.php to debug: open app/app_dev.php and your ip as for config.php. Now you can run scripts as localy using app_dev.php.
Alternative3
I got it to work, this is my experience:
- Upload the whole project folder to the server.
- Enter
www.your-website.com/project-name/web/config.php. - It should say: "This script is only accessible from localhost".
- Open this web site: http://www.whatismyip.com, it should show you your public IP address, copy it.
- Open the config.php from the admin panel (like cPanel) and edit that
config.php:
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', /*your IP here*/))) {
header('HTTP/1.0 403 Forbidden');
die('This script is only accessible from localhost.');
}
- Refresh your
config.phpfile, the page will tell you if your system is missing some required conditions like: PHP version, APC extension, giving /cache and /log folders permissions to write on, etc. - After you provide the required conditions you'll see a form of configuring you project to connect to a database if you have one, this step is pretty simple.
- Open the link
www.your-website.com/project-name/web/app_dev.php, it'll help you get started with Symfony2 project. - In case you got in
app_dev.phpthis message:You are not allowed to access this file...just do the same thing toapp_dev.phpas you did in steps 4 and 5 (add your public IP address to the array).
Note of Hakan Deryal (comment): If you don't have a fix IP address, you need to do this last step each time you get a new IP adrdress from the DHCP. So to solve that, open theapp_dev.phpand comment out the linedie('You are not allowed to.., however this is not a recommended way because you're disabling the built-in security of the file. - One thing stopped me and may stop you too, the server I deployed the
project on, was case-sensitive (unlike the localhost on my computer),
so it kept telling me that the template (
Index.html.phpfor example) does not exist, however it does exist, but I didreturn $this->render('...:index.html.php')with smalliinDefaultController.php. So render the exact template (file) name with the same letters cases.
Thursday, June 6, 2013
Paginator Bundle :: KnpPaginatorBundle
1. Installation
-add to composer.json
-add to composer.json
{ "require": { "knplabs/knp-paginator-bundle": "dev-master" } }
2. configure
- add app/config/config.yml
knp_paginator:
page_range: 5 # default page range used in pagination control
default_options:
page_name: page # page query parameter name
sort_field_name: sort # sort field query parameter name
sort_direction_name: direction # sort direction query parameter name
distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements
template:
pagination: KnpPaginatorBundle:Pagination:sliding.html.twig # sliding pagination controls template
sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template
3. Add to application kernel
- add app/AppKernel.php
public function registerBundles() { return array( // ... new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(), // ... ); }
The controller :
$em = $this->get('doctrine.orm.entity_manager');
$dql = "SELECT a FROM ASFPembedaBundle:Quran a WHERE a.sura = '$surah'";
$query = $em->createQuery($dql);
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$query,
$this->get('request')->query->get('page', 1)/*page number*/,
10/*limit per page*/
);
return $this->render('ASFPembedaBundle:Quran:qsurah.html.twig', array(
'pagination' => $pagination,
'comments' => 'ssssss'
));
The view :
<table border=1>
{# table body #}
{% for ayat in pagination %}
<tr {% if loop.index is odd %}class="snippet"{% endif %}>
<td>{{ ayat.aya }}</td><td>{{ ayat.text }}</td>
</tr>
<tr {% if loop.index is odd %}class="grey"{% endif %}>
<td></td><td>
<div>
<p>{{ ayat.quranmakna.mtext }}</p>
</div>
</td>
</tr>
{% else %}
<p>Search text not found</p>
{% endfor %}
</table>
{# display navigation #}
<div class="navigation">
{{ knp_pagination_render(pagination) }}
</div>
Unknown database type enum requested ...
Installing the FOSuser and get error after the below step command :
php app/console doctrine:schema:update --force
[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform
may not support it.
doctrine:schema:update [--complete] [--dump-sql] [--force] [--em[="..."]]
vi app/config/config.app
add :
php app/console doctrine:schema:update --force
[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform
may not support it.
doctrine:schema:update [--complete] [--dump-sql] [--force] [--em[="..."]]
vi app/config/config.app
add :
mapping_types: enum: string
to the doctrine:dbal:
like this :
doctrine: dbal: driver: %database_driver% host: %database_host% port: %database_port% dbname: %database_name% user: %database_user% password: %database_password% charset: UTF8 mapping_types: enum: string
Subscribe to:
Posts (Atom)