Laravel 4 Cookbook

What This Book Teaches I’m writing this book (and the tutorials) in the hope that people can learn the things I have about Laravel 4. It’s not meant as a replacement for any of the great Laravel books, but instead as a complement to the resources, documentation and framework. This book teaches various aspects of … Continue reading “Laravel 4 Cookbook”

Laravel 4 Cookbook
Christopher Pitt and Taylor Otwell

What This Book Teaches

I’m writing this book (and the tutorials) in the hope that people can learn the things I have about Laravel 4. It’s not meant as a replacement for any of the great Laravel books, but instead as a complement to the resources, documentation and framework.
This book teaches various aspects of Laravel 4 implementation, configuration and usage; as part of separate projects. The idea is not to demonstrate the only or best way to create any of these projects.
It’s not to show the only or best way to use Laravel 4. It’s simply a different (and subjective) kind of documentation to the modularised version found at: While this book touches on in the installation and hosting of Laravel applications; it’s not an
exhaustive reference for how to do these things. There are some instructions; which should be enough to get you up and running, but it assumes you are familiar with how things like LAMP (Linux, Apache, MySQL and PHP) work and are capable of installing and maintaining them.

Why Write This Book
I was learning how to use Laravel 4 more effectively, and found some subjects which I felt were worth sharing. I picked Medium (which later turned out to be a huge pain) and started putting a tutorial together. A few hours later I hit publish…
Then @laravelphp retweeted a link to the article. I think I spent the rest of the day just watching stats. The tutorial hit Medium’s home page. It turns out there are a lot of people who wanted to know about Authentication (in Laravel), and just needed to be exposed to the article through @laravelphp’s promotion of it.
Since then; I have been releasing a tutorial every two weeks.
The book grew out of the realisation that; while loads of people were reading the tutorials on Medium, some people weren’t happy with the platform.
There are many compelling reasons for me to keep on using Medium to host the tutorials. I don’t want to host my own thing because uptime is important, and outages in the night add years onto my life. The simple statistics and text formatting are also great.
I want to stay on Medium, but I also want people to want to read the tutorials and learn from them on other platforms. The book allows both of these things, as well as an important third thing…
The book is also intended as a means to give back to Laravel; in particular the invaluable work of Taylor Otwell. To this end, I have committed to give half of all sales to Taylor. The tutorials will always be free on Medium, and their content will mirror the chapters of this book (with obvious repetition omitted), but by purchasing this book you are helping to fund future Laravel development from him and tutorials from me.

Laravel Application Development Cookbook

Laravel Application Development CookbookLaravel has become one of the fastest growing PHP frameworks ever. With its expressive syntax and excellent documentation, it’s easy to get a fully functioning web application up-and-running in very little time. Additionally, the use of modern PHP features makes Version 4 of Laravel very easy to customize to our own needs and also makes it easy for us to create a highly complex site if need be. It’s a perfect blend of the simple and advanced.
This book covers merely a fraction of all that Laravel is capable of. Think of it more as a starting point, with code examples to get things working. Then customize them, add to them, or combine them to create your own applications. The possibilities are endless.
One of the best things about Laravel is the community. If you’re ever stuck on a problem and doing a Google search isn’t helping, there are always people willing to help out. You can find helpful community members on IRC (#laravel on Freenode) or the forums ( or you can contact the many Laravel users on Twitter.
Happy Laravel-ing!

What this book covers
Chapter 1, Setting Up and Installing Laravel, covers various ways to get Laravel up-and-running.
Chapter 2, Using Forms and Gathering Input, shows many ways to use forms in Laravel. It covers using Laravel’s form class as well as some basic validation.
Chapter 3, Authenticating Your Application, demonstrates how to authenticate users. We’ll see how to use OAuth, OpenId, and various social networks for authentication.
Chapter 4, Storing and Using Data, covers all things data, including how to use data sources other than a MySQL database.
Chapter 5, Using Controllers and Routes for URLs and APIs, introduces various routing methods in Laravel and how to make a basic API.
Chapter 6, Displaying Your Views, demonstrates how views work in Laravel. We’ll also incorporate the Twig templating system and Twitter Bootstrap.
Chapter 7, Creating and Using Composer Packages, explains how to use packages in our app as well as how to create our own package.
Chapter 8, Using Ajax and jQuery, provides different examples of how to use jQuery in Laravel and how to make asynchronous requests.
Chapter 9, Using Security and Sessions Effectively, covers topics about securing our application and how to use sessions and cookies.
Chapter 10, Testing and Debugging Your App, shows how to include unit testing in our app with PHP Unit and Codeception.
Chapter 11, Deploying and Integrating Third-party Services into Your Application, introduces a number of third-party services and how we can include them in our application.

Network Analysis Using Wireshark Cookbook

Network Analysis Using Wireshark Cookbook

Wireshark has long become the market standard for network analysis, and with the growth of the Internet and TCP/IP-base d networks, it became very popular for network analysis, troubleshooting, as well as for R&D engineers to understand what is actually running over the network and what are the problems that we face.

This book is written from a practical point of view. The first part of it, from Chapter 1, Introducing Wireshark, to Chapter 6, Using the Expert Infos Window, describes the Wireshark software and how to work with it. This includes how to start it, where to locate it in the network, how to work with statistical tools, and how to use the Expert system. The second part, from Chapter 7, Ethernet, LAN Switching, and Wireless LAN, to Chapter 14, Understanding Network Security, describes how to use it for the analysis and troubleshooting of common networking protocols; among them, the TCP/IP protocol stack with emphasis on TCP performance issues, common Internet protocols such as HTTP, SMTP, POP and DNS, databases, Citrix and Microsoft Terminal Server, IP telephony, and multimedia applications.

The last chapter is about network security. It describes how to locate security breaches and other problems in your network. As the name of the book implies, this is a Cookbook. It is a list of effective, targeted recipes of how to analyze networks. Every recipe comes with a specific issue, how to use Wireshark for it, where to look and what to look for, and what is the reason for what you see. To complete the picture, every recipe provides the theoretical foundations of the subject, in order to give the reader the required theoretical background.
You will see many examples in the book, and all of them are real cases. Some of them took me minutes to solve, some hours, and some of them took many days. There is one thing common to all of them: work systematically, use the proper tools, try to get inside the head of the application writer, and like someone told me once, “Try to think like the network”. Do this, use Wireshark, and you will get results. The purpose of this book is to try and get you there. Have fun!

What this book covers

Chapter 1, Introducing Wireshark, starts with introducing Wireshark, explaining where to locate it for effective network analysis. We will learn how to configure the basic parameters, the start window, the time values, and the coloring rules; and most importantly, we will learn how to use the Preferences window.

Chapter 2, Using Capture Filters, explains how to use capture filters which are used in order to define what data will be captured. This chapter explains how to configure these filters and how to use them in order to capture only the desired data.
Chapter 3, Using Display Filters, explains how to configure display filters which are used in order to display only the desired data, after the data is captured. This chapter explains how to configure these filters and how they can assist us in network troubleshooting.
Chapter 4, Using Basic Statistics Tools, explains how to work with the basic Wireshark statistical features, starting from the simple tables that provides us with “who is talking” information, conversations and HTTP statistics, and others.
Chapter 5, Using Advanced Statistics Tools, explains how to work with the advanced Wireshark statistical features, including the IO graphs and TCP stream graphs that provides us with powerful capabilities for network and application performance analysis. Chapter 6, Using the Expert Infos Window, explains how to work with the Expert system, which is a powerful tool that pinpoints various types of events, such as TCP retransmissions, zero-window, low TTL and routing loops, out-of-order segments, and other events that might influence the behavior of our network.
Chapter 7, Ethernet, LAN Switching, and Wireless LAN, explains the Ethernet protocol and LAN switching, along with problems that might occur in this layer. It also focuses on Wireless LAN (WiFi), how to test it, and how to resolve problems in these networks.
Chapter 8, ARP and IP Analysis, explains about ARP, IP, and how to analyze IP connectivity and routing problems. This chapter also explains how to find duplicate IP addresses, DHCP problems, and other related issues.
Chapter 9, UDP/TCP Analysis, focuses on layer 4 protocols, TCP, and UDP, with emphasis on TCP performance issues. It provides recipes for allocation of TCP performance problems, such as retransmission, duplicate ACKs, sliding-window problems such as window-full and zero-window, resets, and other related issues.
Chapter 10, HTTP and DNS, focuses on DNS, HTTP, and HTTPs. In this chapter, we will see how they work and what can go wrong in these protocols.
Chapter 11, Analyzing Enterprise Applications’, Behavior, talks about other applications such as FTP, mail protocols, terminal services, and databases. We will see how they are affected by network problems and how we can solve network-related problems in these applications.
Chapter 12, SIP, Multimedia, and IP Telephony, is about voice and video over IP, including recipes for finding VoIP SIP connectivity problems, RTP/RTCP performance problems, and video problems such as picture freezing and bad picture quality.
Chapter 13, Troubleshooting Bandwidth and Delay Problems, provides recipes for finding problems caused by low-bandwidth, high-delay, and high-jitter networks. The chapter explains the behavior of TCP over high-delay, high-jitter networks, and what we can do in order to improve this behavior.
Chapter 14, Understanding Network Security, focuses on TCP/IP-based network security, and it includes recipes for finding network scanning, SYN attacks, DOS/DDOS, and other attacks that can harm the network. This chapter provides recipes for finding various attack patterns and what causes them.
Appendix, Links, Tools, and Reading, provides references to some useful links from which you can get further information about Wireshark: learning sources, additional software, and so on.

Mathematica Cookbook

Mathematica cookbook

If you were stranded on a desert island with only your laptop (and presumably a large solar panel), what software would you want to have with you? For me the answer definitely includes the latest version of Wolfram Mathematica. Whether you are a scientist, engineer, or mathematician, a Wall Street quant, a statistician or programmer, or even an artist or musician, you will be a better one if you have this tool at your disposal. Of course, having a tool and knowing how to use it well are quite different things. That is why I wrote the Mathematica Cookbook.
I am abig fan of O’Reilly cookbooks, as these books are designed to help you solve real-world problems. Mathematica is an ideal candidate for a cookbook because it is so vast, deep, and full of traps for the novice. I was ecstatic to learn that O’Reilly was looking to publish a Mathematica cookbook and even more excited when I was chosen to be its author. I have been a use r of Mathematica since version 3.0. Although that was over 13 years ago, I still remember the frustration of trying to solve problems in this system. I don’t mean this in a derogatory way. The frustration a newbie experiences when trying to learn Mathematica comes from the knowledge that you are sitting in front of a highly advanced computational platform that eventually will magnify your productivity tenfold—if you can only wrap your mind around its unfamiliar idioms. If you are a new (or even not-so-new) user of Mathematica today, you
are simultaneously in a better and a much worse position than I was with version 3.0.
You are in a better position because Mathematica 7.0 is vastly more powerful than 3.0 was back then. Not only has the number of available functions doubled, but Mathematica has fundamental new capabilities including dynamic interactivity, curated data sources, parallel processing, image processing, and much more. You are in a worse position because there is much more to learn! As Mathematica grows, it remains largely unchanged in its core principles. This book is designed to help you master those core principles by presenting Mathematica in the context of real-world problems. However, my goal is not just to show you how to solve problems in Mathematica, but to show you how to do so in a way that plays to Mathematica’s strengths. This means there is an emphasis on symbolic, functional, and pattern-based styles of programming. Mathematica is a multi-paradigm programming language; you can easily write code in it that a Fortran or C programmer would have little trouble following. However, the procedural style that this entails is not likely to give you good performance. More importantly, it will often cause you to write more code than necessary and spend more time adapting that code to future problems. Stephen Wolfram has said that a correct Mathematica program is often a short Mathematica program. There is much truth to this. The truth comes from the idea that good Mathematica programs leverage the capabilities of the vast built-in library of both general-purpose and highly specialized functions. Programming in Mathematica is a search for the right combination of primitives. My hope is that this cookbook will play a role as your guide.

CodeIgniter 2 Cookbook

CCI2CookbookAs a developer, there are going to be times when you’ll need a quick and easy solution to a coding problem. CodeIgniter is a powerful open source PHP framework which allows you to build simple yet powerful full-feature web applications.

CodeIgniter 2 Cookbook offers many easy-to-use, easy-to-integrate, and easy-to-adapt recipes using HTTPS, image manipulation, cookie acceptance, form validation, and so on. It is a great
resource for 2 AM problems.

What this book covers
Chapter 1, CodeIgniter Basics, takes you through CodeIgniter’s download and installation, basic configuration, and so on.
Chapter 2, User Management, focuses on building a basic CRUD interface for managing users.
Chapter 3, Creating E-commerce Features, explores the use of the CodeIgniter Cart class to create a simple storefront, allowing a customer to add items to the cart and checkout.
Chapter 4, Email, HTML Table, and Text Libraries, focuses on sending e-mails using the CodeIgniter Email library, creating interactive tables, and using a few handy HTML functions.
Chapter 5, Managing Data In and Out, deals with form validation, writing files to disk, confirming cookie acceptance from the user, and so on.
Chapter 6, Working with Databases, covers the usage of basic Active Record functions, exporting data from a database query binding, and most of what you might need to work with databases.
Chapter 7, Creating a Secure User Environment, covers escaping user input, switching to and from HTTPS in CodeIgniter, and so on.
Chapter 8, Calendaring, Right Place, and Right Time, deals with creating an interactive calendar that you can add appointments to using fuzzy dates and calculating a person’s date of birth (for age verification)
Chapter 9, Extending the Core, focuses on using the language class and switching languages on the go, creating hooks, uploading files with FTP, and extending your controllers with MY_Controller.
Chapter 10, Working with Images, deals with using the CodeIgniter image manipulation library to crop, rotate, and add watermarks to images and adding CAPTCHA validation to forms.
Chapter 11, SEO, Caching, and Logging, deals with caching data from a database, using the CodeIgniter routing methods to alter and amend how URLs are displayed in a browser’s address bar, and logging errors and other activities throughout your application.

Raspberry Pi Networking Cookbook

Raspberry Pi Networking CookbookThe Raspberry Pi is more than just a platform for teaching students how to program computers! The recipes in this book show you how this inexpensive computer can be used out of the box for a number of practical solutions that utilize existing networks and connectivity. The Raspberry Pi Networking Cookbook is an essential reference full of practical solutions for use both at home and in the office. Beginning with step-by-step instructions for installation and configuration, this book can either be read from cover to cover or treated as an essential reference companion to your Raspberry Pi. Full of practical and engaging content designed to expand and build upon your existing skills as you work through individual recipes, any computer novice can quickly learn how to become a Raspberry Pi expert without any programming knowledge required. The Raspberry Pi Networking Cookbook will allow you to revolutionize how you use technology on a daily basis, ranging from sharing your media across multiple devices to deploying your very own web portal, or even accessing your desktop remotely.

Yii Application Development Cookbook

YiiThe Yii framework is a rapidly growing PHP5 MVC framework often referred to as Rails for PHP. It has already become a solid base for many exciting web applications such as and can be a good base for your developments, too.

This book will help you to learn Yii quickly and in more depth for use in for your developments. Yii Application Development Cookbook will show you how to use Yii efficiently. You will learn about taking shortcuts using core features, creating your own reusable code base, using test driven development, and many more topics that will give you a lot of experience in a moderate amount of time.