Book Image

PHP Application Development with NetBeans: Beginner's Guide

By : M A Hossain Tonu
Book Image

PHP Application Development with NetBeans: Beginner's Guide

By: M A Hossain Tonu

Overview of this book

<p>NetBeans has many features that greatly simplify PHP development, and with its several features and great flexibility, PHP developers can become overwhelmed by the IDE's options. This book provides step-by-step instructions that show you how to take control of the environment and make use of these features to make your PHP application development more efficient and productive than ever before.<br /><br />"PHP Application Development with NetBeans: Beginner's Guide" leads you through the crucial parts of PHP programming and shows you how to use the features of NetBeans that will improve your PHP development experience, through clear and easy instructions.<br /><br />The book gets you started with the development environment and tools, and takes you through working on practical projects with a clear focus. With each chapter being mission-critical, the book is a perfect companion to boost your PHP coding productivity and gain experience with even complex projects.<br /><br />The book starts with setting up the PHP development environment and introduces exciting and useful IDE features. You'll learn how to build real life PHP projects such as Facebook like Status Updater and even User Registration, Login &amp; Logout application. Also the book will introduce you with some must know development tools such as debugging &amp; testing tools, source documenter tools, and versioning tools.<br /><br />Working with the NetBeans IDE for PHP development has its own advantages, and this book reassures the purpose. This book is full of illustrations, screenshots, and clear instructions to take your PHP development to a new level and even shows you time-saving tricks and other productivity enhancements.</p>
Table of Contents (16 chapters)
PHP Application Development with NetBeans Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Time for action — creating a bundle using the Symfony2 console command


We are going to create a new bundle with the generate:bundle command using the IDE's Run Symfony2 Command dialog box. So let's try that...

  1. 1. In the Projects pane, right-click on the Projects node, and from the context menu choose Symfony2 | Run Command... to launch the Run Symfony2 Command dialog box, as follows:

    You will be able to see a list of the available commands in the Matching Tasks box. You can add parameters for those commands and see the complete command in the Command dialog box.

  2. 2. From the preceding dialog box, select the generate:bundle command and click on Run, or double-click on the listed name to run the command. The IDE's graphical console opens for prompting the namespace.

  3. 3. Enter the value for Bundle namespace, say Application/FooBundle.

  4. 4. Enter the value for Bundle name or press Enter to accept the default bundle name as ApplicationFooBundle.

  5. 5. Press Enter at the Target directory to accept the default bundle path as /src.

  6. 6. You may enter the value for Configuration format (yml, xml, php, or annotation) as yml; the default value is annotation.

  7. 7. Enter Yes for Do you want to generate the whole directory structure [no]? to generate a whole directory structure for the bundle; the default is no.

  8. 8. Confirm the bundle generation by entering Yes again.

  9. 9. At Confirm automatic update of your Kernel [yes]? and Confirm automatic update of the Routing [yes]?, press Enter to accept the default value, which is yes. So the bundle can be registered in the Symfony kernel and the bundle routing file is linked to the default routing configuration file.

  10. 10. Now, as you can see, a new bundle has been created inside the /src directory; the bundle directory structure looks similar to the following:

    Note that the default controller, route file, template, and so on have been created simultaneously with the bundle creation.

  11. 11. Now, to test your bundle, point your browser to http://localhost/symfony2/web/app_dev.php/hello/tonu, and you may see an output similar to Hello Tonu!

  12. 12. Check out the bundle routing file at /src/Application/FooBundle/Resources/config/routing.yml, and you will see the URL with the pattern /hello/{name} mapped with the default controller's index action (ApplicationFooBundle:Default:index). In this example, the action displays the name passed as the URL parameter in place of {name}.

What just happened?

Each bundle is hosted under a namespace (such as Acme/Bundle/BlogBundle or Acme/BlogBundle). The namespace should begin with a "vendor" name, such as your company name, your project name, or your client name, followed by one or more optional category subnamespaces, and it should end with the bundle name itself (which must have Bundle as a suffix).

Note

See http://symfony.com/doc/current/cookbook/bundles/best_practices.html#index-1 for more details on bundle naming conventions.

We have seen the interactive console that asks for arguments and creates the entire bundle directory structure automatically. Also, it registers the bundle into Symfony's /app/AppKernel.php, and links the bundle routing configuration file into default/app/config/routing.yml.

Note

Symfony learning resource:

http://symfony.com/doc/current/book/index.html