Symfony 2 Tutorial. Model. Neues Bundle erstellen: php app/console generate:bundle --namespace=blogger/blogbundle



Similar documents
Practical Guided Tour of Symfony

<link rel="stylesheet" type="text/css" media="all" href="css/iphone.css" /> <!-- User defined styles -->

BUILDING MOBILE WEB APPS WITH PHONEGAP. Matt Zukowski

WA 2. GWT Martin Klíma

Wicket Application Development

Agenda. 1. ZAPms Konzept. 2. Benutzer-Kontroller. 3. Laout-Aufbau. 4. Template-Aufbau. 6. Konfiguration. 7. Module.

HAML und SASS. (und COMPASS) markup haiku vs. syntactically awesome stylesheets. Tobias Adam, Jan Krutisch mindmatters GmbH & Co.

Open-Source Shopping Cart Solutions. Installation information for integrating a shopping cart with Checkout by Amazon using open-source solutions

Mobile Web Applications using HTML5. L. Cotfas 14 Dec. 2011

Drupal CMS for marketing sites

.NET Best Practices Part 1 Master Pages Setup. Version 2.0

Web Development in Java Live Demonstrations (Live demonstrations done using Eclipse for Java EE 4.3 and WildFly 8)

Installing Java (Windows) and Writing your First Program

Creating a Drupal 8 theme from scratch

Secure Testing Service

Facebook Twitter YouTube Google Plus Website

SEO Content Writing Guide

PHP and XML. Brian J. Stafford, Mark McIntyre and Fraser Gallop

Django Assess Managed Nicely Documentation

Differences between HTML and HTML 5

Google Web Toolkit. Progetto di Applicazioni Software a.a. 2011/12. Massimo Mecella

ShoreTel Enterprise Contact Center 8 Installing and Implementing Chat

AD Phonebook 2.2. Installation and configuration. Dovestones Software

How to Customize Support Portals

Example for Using the PrestaShop Web Service : CRUD

Written by Wirabumi Software Sunday, 30 December :27 - Last Updated Thursday, 03 January :52

Java Server Pages combined with servlets in action. Generals. Java Servlets

GEMFIND. We Handle The Journey. So You Can Focus On The Destination. WEB TECHNOLOGIES FOR THE JEWELRY INDUSTRY - Est. 1999

Joomla 1.0 Extension Development Training. Learning to program for Joomla

Using the VMRC Plug-In: Startup, Invoking Methods, and Shutdown on page 4

OPENTABLE GROUP SEARCH MODULE GETTING STARTED ADD RESERVATIONS TO YOUR WEBSITE

<div class="juego"> <canvas id="canvas" width="600" height="650">tu NAVEGADOR NO SOPORTA HTML5!</canvas> </div> </div> </body> </html>

Localizing dynamic websites created from open source content management systems

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Introduction to Eclipse

SESM Tag Library. Configuring a Tag Library APPENDIX

Links Getting Started with Widgets, Gadgets and Mobile Apps

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

Ready, Set, Go Getting started with Tuscany

PHP Debugging. Draft: March 19, Christopher Vickery

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

SizmekFeatures. HTML5JSSyncFeature

Drupal 8. Core and API Changes Shabir Ahmad MS Software Engg. NUST Principal Software Engineser PHP/Drupal

Configuring the Bundled SESM RADIUS Server

Symfony2 and Drupal. Why to talk about Symfony2 framework?

Nifty web apps on an OpenResty

Drupal 8 Theming. Exploring Twig & Other Frontend Changes CROWD. Communications Group, LLC CROWD. Communications Group, LLC

Web Applications Testing

HTML Fails: What No One Tells You About HTML

How To Customize A Forum On Vanilla Forum On A Pcode (Forum) On A Windows (For Forum) On An Html5 (Forums) On Pcode Or Windows 7 (Forforums) On Your Pc

How To Analyze Logs On Aloha On A Pcode On A Linux Server On A Microsoft Powerbook (For Acedo) On A Macbook Or Ipad (For An Ubuntu) On An Ubode (For Macrocess

To reduce or not to reduce, that is the question

Microsoft SQL connection to Sysmac NJ Quick Start Guide

Hello friends, This is Aaditya Purani and i will show you how to Bypass PHP LFI(Local File Inclusion)

Web development... the server side (of the force)

Subject Tool Remarks What is JQuery. Slide Javascript Library

HTML and CSS. Elliot Davies. April 10th,

Pete Helgren Ruby On Rails on i

Web-based IDE for Interfacing View Controller

Implementing Sub-domain & Cross-domain Tracking A Complete Guide

EXT: SEO dynamic tag

Ansible. Configuration management tool and ad hoc solution. Marcel Nijenhof

Building Android Apps with HTML, CSS, and JavaScript

latest Release 0.2.6

Web Design Course. Home Page. Join in. Home. Objectives. Course Content. Assignments & Discussion. Grades. Help. Contact Me aab43@uakron.

INFORMATION BROCHURE Certificate Course in Web Design Using PHP/MySQL

BUILD A MOBILE APP WITH HTML5 AND JAVASCRIPT

Static webpages with Pelican

Apache Hadoop 2.0 Installation and Single Node Cluster Configuration on Ubuntu A guide to install and setup Single-Node Apache Hadoop 2.

Intro to Web Programming. using PHP, HTTP, CSS, and Javascript Layton Smith CSE 4000

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Application Development Guide for

Web Authoring CSS. Module Descriptor

Web Programming Step by Step

2. Boot using the Debian Net Install cd and when prompted to continue type "linux26", this will load the 2.6 kernel

Welcome to CSE 330 Crea0ve Progamming and Rapid Prototyping. Course Informa0on

Managing Snort Alerts

Developer Tutorial Version 1. 0 February 2015

Running Knn Spark on EC2 Documentation

WebIOPi. Installation Walk-through Macros

Script Handbook for Interactive Scientific Website Building

Testking.M Q

Client SuiteScript Developer s Guide

Setup The package simply needs to be installed and configured for the desired CDN s distribution server.

Cloud Powered Mobile Apps with Azure

DIPLOMA IN WEBDEVELOPMENT

Modern Web Application Framework Python, SQL Alchemy, Jinja2 & Flask

Medooze MCU Video Multiconference Server Installation and configuration guide Ubuntu LTS

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

Citrix StoreFront. Customizing the Receiver for Web User Interface Citrix. All rights reserved.

Transcription:

Symfony 2 Tutorial Neues Bundle erstellen: php app/console generate:bundle --namespace=blogger/blogbundle Eintrag erfolgt in app/appkernel.php und app/config/routing.yml. Model Available types: array, object, boolean, integer, smallint, bigint, string, text, datetime, datetimetz, date, time, decimal, float. php app/console doctrine:generate:entity --entity="bloggerblogbundle:post" -- fields="category_id:integer title:string(255) content:text created_at:datetime updated_at:datetime" php app/console doctrine:generate:entity --entity="bloggerblogbundle:tag" -- fields="name:string(255) created_at:datetime" php app/console doctrine:generate:entity --entity="bloggerblogbundle:category" -- fields="name:string(255) created_at:datetime"

Relations Post: src/blogger/blogbundle/entity/post.php use Doctrine\Common\Collections\ArrayCollection; @ORM\Entity @ORM\Table(name="post") @ORM\Entity(repositoryClass="Blogger\BlogBundle\Entity\PostRepository") @ORM\HasLifecycleCallbacks @ORM\ManyToOne(targetEntity="Category") @ORM\JoinColumn(name="category_id", referencedcolumnname="id") @var Category $category protected $category; @ORM\ManyToMany(targetEntity="Tag") @ORM\JoinTable(name="post_tag", joincolumns=@orm\joincolumn(name="post_id", referencedcolumnname="id"), inversejoincolumns=@orm\joincolumn(name="tag_id", referencedcolumnname="id") ) @var ArrayCollection $tags protected $tags; Constructs a new instance of Post. public function construct() $this->created_at = $this->updated_at = new \DateTime("now"); $this->tags = new ArrayCollection(); Invoked before the entity is updated. @ORM\PreUpdate public function preupdate() $this->updated_at = new \DateTime("now");

Category: src/blogger/blogbundle/entity/category.php use Doctrine\Common\Collections\ArrayCollection; Blogger\BlogBundle\Entity\Category @ORM\Table(name="category") @ORM\Entity(repositoryClass="Blogger\BlogBundle\Entity\CategoryRepository") @ORM\OneToMany(targetEntity="Post", mappedby="category") @var ArrayCollection $posts protected $posts; public function construct() $this->posts = new ArrayCollection(); $this->created_at = new \DateTime("now"); public function tostring() return $this->name; Tag: src/blogger/blogbundle/entity/tag.php use Doctrine\Common\Collections\ArrayCollection; Blogger\BlogBundle\Entity\Tag @ORM\Table(name="tag") @ORM\Entity(repositoryClass="Blogger\BlogBundle\Entity\TagRepository") @ORM\ManyToMany(targetEntity="Post", mappedby="tags") @var ArrayCollection $posts protected $posts; public function construct() $this->posts = new ArrayCollection(); $this->created_at = new \DateTime("now"); public function tostring() return $this->name;

Generating Getters and Setters php app/console doctrine:generate:entities Blogger Creating the Database Tables/Schema php app/console doctrine:schema:update force CRUD creation: php app/console generate:doctrine:crud BloggerBlogBundle:Post BloggerBlogBundle:Category BloggerBlogBundle:Tag Formulare ausmisten (unnötige Felder entfernen) src/blogger/blogbundle/form/

Templating src/blogger/blogbundle/resources/views/default/layout.html.twig <!DOCTYPE HTML> <html> <head> % set bundlepath = 'bundles/bloggerblog/' % <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>symfony2 tutorial</title> % block stylesheets % <link href=" asset( bundlepath ~ 'css/main.css') " type="text/css" rel="stylesheet" /> % endblock % % block javascripts % <script src=" asset( bundlepath ~ 'js/jquery-1.7.1.min.js') " type="text/javascript"></script> <script src=" asset( bundlepath ~ 'js/main.js') " type="text/javascript"></script> % endblock % </head> <body> <div id="wrapper"> <div id="header"> <h1>tutorial</h1> <ul> <li><a href=" path('post') ">Posts verwalten</a></li> <li><a href=" path('category') ">Kategorien verwalten</a></li> <li><a href=" path('tag') ">Tags verwalten</a></li> </ul> </div> <div id="page-body"> % block body %% endblock % </div> <div id="footer"> % include 'BloggerBlogBundle:Default:footer.html.twig' % </div> </div> </body> </html> src/blogger/blogbundle/resources/views/default/footer.html.twig <p>das ist der Footer</p>

src/blogger/blogbundle/resources/views/category/index.html.twig % extends 'BloggerBlogBundle:Default:layout.html.twig' % % block javascripts % parent() <script src=" asset( bundlepath ~ 'js/xxxxxx.js') " type="text/javascript"></script> % endblock % % block body %... % endblock % Install assets php app/console assets:install web

Using relations src/blogger/blogbundle/resources/views/post/index.html.twig <th>categoryname</th> <td> entity.getcategory </td> <tr class= taglist > <td colspan="8"> Tags: % for tag in entity.gettags % <a href=" path('tag_show', 'id': tag.id ) "> tag.name </a> % endfor % </td> </tr> src/blogger/blogbundle/resources/views/tag/show.html.twig <h2>posts mit dem Tag entity.name </h2> <table class="tagposts"> <tr> <th>id</th> <th>post title</th> </tr> % for post in entity.getposts % <tr> <td> post.id </td> <td><a href=" path('post_show', 'id': post.id ) "> post.title </a></td> </tr> % endfor % </table> src/blogger/blogbundle/resources/views/category/show.html.twig <h2>posts mit der Katgorie entity.name </h2> <table class="categoryposts"> <tr> <th>id</th> <th>post title</th> </tr> % for post in entity.getposts % <tr> <td> post.id </td> <td><a href=" path('post_show', 'id': post.id ) "> post.title </a></td> </tr> % endfor % </table>

String Translation app/config/config.yml framework: #esi: ~ translator: fallback: de @Route("/") @Template() public function rootaction() $request = $this->getrequest(); $session = $request->getsession(); $lang = $this->getrequest()->getpreferredlanguage(array('de','en')); $session->setlocale($lang); return $this->redirect($this->generateurl('index')); @Route("_locale/index/", name="index", requirements="_locale"="de en") @Method("GET") @Template() public function indexaction() echo $this->get('translator')->trans('willkommen'); return array(); src/blogger/blogbundle/resources/views/default/index.html.twig % extends 'BloggerBlogBundle:Default:layout.html.twig' % % block body % % trans %Willkommen% endtrans % % endblock % src/blogger/blogbundle/resources/translations/messages.en.php <?php return array( 'Willkommen' => 'Welcome' );?> Parameter use Symfony\Component\HttpFoundation\Response; @Route("/parameter/id/id2", name="parameter", requirements="id" = "\d+", defaults="id2" = "kein wert") @Method("GET") @Template() public function parameteraction($id, $id2) return new Response('Parameter1: '.$id. ' Parameter2: '.$id2);

Minify JavaScripts and Stylesheets with YUI Compressor apt-get install yui-compressor src/blogger/blogbundle/resources/views/default/layout.html.twig % stylesheets '@BloggerBlogBundle/Resources/public/css/' output='css/compressed.css' filter='?yui_css' % <link rel="stylesheet" href=" asset_url " type="text/css" media="screen" /> % endstylesheets % % javascripts '@BloggerBlogBundle/Resources/public/js/' output='js/compressed.js' filter='?yui_js' % <script src=" asset_url "></script> % endjavascripts % Also in dev mode filter='yui_css' filter='yui_js' app/config/config.yml # Assetic Configuration assetic: debug: "%kernel.debug%" use_controller: false # Uncomment the following line if your java bin is # in a different location # java: /usr/bin/java filters: cssrewrite: ~ yui_css: jar: /usr/share/yui-compressor/yui-compressor.jar yui_js: jar: /usr/share/yui-compressor/yui-compressor.jar php app/console --env=prod assetic:dump

Google Closure Compiler apt-get install sun-java6-jdk sun-java6-plugin update-java-alternatives -s java-6-sun Once either one is done, run the sudo update-java-alternatives -s java-6-sun command and finally add the line /usr/lib/jvm/java-6-sun to the top of the /etc/jvm file (gksudo gedit /etc/jvm). Save and exit. To test your Java(TM) setup in the terminal type:- mkdir /usr/share/closure-compiler cd /usr/share/closure-compiler wget http://closure-compiler.googlecode.com/files/compiler-latest.zip. unzip compiler-latest.zip src/blogger/blogbundle/resources/views/default/layout.html.twig % javascripts '@BloggerBlogBundle/Resources/public/js/' output='js/compressed.js' filter='closure' % <script src=" asset_url "></script> % endjavascripts % app/config/config.yml # Assetic Configuration assetic: debug: %kernel.debug% use_controller: false # java: /usr/bin/java filters: cssrewrite: ~ closure: jar: /usr/share/closure-compiler/compiler.jar php app/console --env=prod assetic:dump