Symfony2 Essentials
eBook - ePub

Symfony2 Essentials

  1. 158 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Symfony2 Essentials

About this book

A fast-paced developer's guide to using Symfony2 to make your everyday web development work more efficient

About This Book

  • Build web applications with the latest features of Symfony2
  • Focus on common tasks such as creating CRUD, creating an API, and providing a login
  • Install and configure Symfony2 and evaluate it for your everyday needs

Who This Book Is For

This book is aimed at experienced programmers, especially those familiar with a closely related technology such as Yii or Laravel, but who now want to learn Symfony quickly.

This book will also prove beneficial for experienced PHP developers who want to explore and evaluate new frameworks and their possibilities in day-to-day tasks.

What You Will Learn

  • Familiarise yourself with the Symfony framework, its latest features, and how to install it
  • Discover the concept of bundles and their application
  • Handle translations within Symfony, enable translations, and learn how to handle database translations
  • Understand Symfony's security model, how to secure applications, and implement a custom authentication provider by using FOSUserBundle
  • Explore the use of Twig, find best practices around its usage, and discover its common pitfalls
  • Create internal commands that will handle sending e-mail reminders for your app
  • Develop a plugin for the profiler to provide custom information about your application
  • Deploy applications based on Symfony2 using various methods including simple FTP copying, rsync, CI deployment, and more

In Detail

Symfony is a free and open source PHP MVC web application development framework, which helps you create and maintain web applications and replace recurrent coding tasks. It integrates with an independent library, PHPUnit, to give you a rich testing framework. It is one of the best and most popular frameworks available on the market. Popular projects such as Drupal, Laravel, and phpBB also use Symfony. Its well-organized structure, clean code, and good programming practices make web development a breeze.

Symfony2 Essentials will guide you through the process of creating a sample web application with Symfony2. You will create a To-Do application, using a few of the most commonly used Symfony2 components, and discover how to perform these development tasks efficiently.

This book introduces you to the Symfony framework with a quick installation guide and a brief explanation of its key features including the MVC architecture, twig templating, dependency injection, and more. You will learn to manage dependencies, create controllers, views, and API calls, and secure your application.

Next, you will go through the steps that are common for most web applications, which include writing CRUD and AJAX, handling forms, validation, translations, and the command-line interface, and e-mail sending features. The book ends with best practices, debugging, profiling, and deployment procedures.

By the end of this book, you will have learned how to combine a Symfony2 framework with other open source code to speed up the development process.

Style and approach

A fast-paced, step-by-step guide with examples on how to write the most common pieces of code while developing typical web applications with Symfony.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Symfony2 Essentials


Table of Contents

Symfony2 Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. The Symfony Framework – Installation and Configuration
Key reasons to choose Symfony2
The history of Symfony
Installation
Installing Symfony2 using an installer
The Symfony2 directory structure
What is a bundle?
Composer
The configuration files
The Symfony2 console
Summary
2. Your First Pages
Everything is a bundle
The configuration format
Cleanups
Recreating AppBundle
Routing
Templates – the View layer
Entities – the Model layer
Migrations
Fixtures
Summary
3. Twig Templating and Assets Handling
The Twig templating engine
Assets management
Assetic
Handling third-party bundle assets
Handling your application assets
Creating a list of tasks
Summary
4. Forms
Form creation
Validation and form processing
Theming form elements
Transforming data
Summary
5. Security and Handling Users
Security handling
Installing the user manager bundle
User registration
Summary
6. Translation
Translations
Using translations in a controller
Translation file formats
Variables and pluralization
The translation strategy
Using translation keys
Database translations
Summary
7. AJAX
Installing and configuring REST features
FOSRestBundle
NelmioApiDocBundle
FOSJSRoutingBundle
Refactoring the existing code
Adding a new controller
Setting up routing and JavaScript
Summary
8. Command-line Operations
Creating the console command
Swiftmailer
Logging
Summary
9. Symfony2 Profiler and Debugger
The Web Debug Toolbar
The Symfony2 profiler
The profiler sections
VarDumper
The AJAX requests
Data collectors
The stopwatch component
Summary
10. Preparing an Application for Production
Preparing an application
Checking the code against debug code
Customizing error pages
Verifying the production server requirements
Security check
Updating the basic assets and metadata
Changing the web root directory
Deployment strategies
FTP
The rsync deployment
Continuous integrations
Deployment tools
Platform as a Service deployment
Summary
Index

Symfony2 Essentials

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2015
Production reference: 1040915
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-876-7
www.packtpub.com

Credits

Author
Wojciech Bancer
Reviewers
Cristian Bujoreanu
Olivier Pons
Commissioning Editor
Usha Iyer
Acquisition Editor
Reshma Raman
Content Development Editor
Arwa Manasawala
Technical Editor
Shiny Poojary
Copy Editor
Kausambhi Majumdar
Project Coordinator
Shweta H Birwatkar
Proofreader
Safis Editing
Indexer
Tejal Soni
Production Coordinator
Manu Joseph
Cover Work
Manu Joseph

About the Author

Wojciech Bancer has a master's degree in computer science. He has over 10 years of experience in web application development. In 2007, after passing the Zend exam, he received a Zend Certified Engineer for PHP5 certificate. He started his career as a freelancer and consultant by developing web applications in PHP 4 and PHP 5. He has led many IT projects for clients in Europe and USA. Currently, Wojciech is a managing partner of a software organization and is in charge of the R&D structure of one of the fastest growing iBeacon projects in Europe.

About the Reviewers

Cristian Bujoreanu is a web developer originally from Romania and is currently based in ZĂŒrich, Switzerland. He specializes in web development and has a solid understanding of web application development processes, right from layout / user interface to relational database structures. He creates usable, professional, and user-friendly web applications according to the latest standards and innovative technologies.
Cristian has been in this field for nearly 7 years. He loves his work and enjoys every new project that he's involved in. After spending 4 years working for two web agencies in Romania, he moved to Switzerland in early 2012. He joined joiz, a social TV station with headquarters in ZĂŒrich. In February 2015, he started a new venture at Teamup Solutions AG.
Olivier Pons is a senior developer who has been building websites since 1997. He's a teacher at the University of Sciences (IUT) in Aix-en-Provence in France, ISEN (Institut SupĂ©rieur de l'Électronique et du NumĂ©rique), G4 Marseille, and École d'IngĂ©nieurs des Mines de Gardanne. He teaches state-of-the-art web techniques in NodeJS, big data / NoSQL, the fundamentals of MVC, the basics of Symfony, WordPress, PHP, HTML, CSS, jQuery and jQuery Mobile, AngularJS, Apache, the basics of Linux, and advanced VIM techniques. He has already done some technical reviews, including the Packt Publishing books Learning ExtJS, Ext JS 4 First Look, jQuery hotshot, jQuery Mobile Web Development Essentials, Wordpress 4.x Complete, and jQuery 2.0 for Designers Beginner's Guide, among others. In 2011, Olivier left a full-time job as a Delphi developer and PHP expert to concentrate on his own company, HQF Development (http://hqf.fr). He runs a number of websites, including http://krystallopolis.fr, http://artsgaleries.com, http://www.battlesoop.fr, http://www.livrepizzas.fr, http://www.papdevis.fr, and http://olivierpons.fr, his own web development blog. Currently, he's learning Unity and building a game on his own. He works as a consultant, teacher, and project manager. Sometimes, he also helps big companies as a senior and highly skilled developer.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book, please visit www.PacktPub.com.
Di...

Table of contents

  1. Symfony2 Essentials

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Symfony2 Essentials by Wojciech Bancer in PDF and/or ePUB format, as well as other popular books in Computer Science & Web Development. We have over one million books available in our catalogue for you to explore.