background preloader

Laravel

Facebook Twitter

Shellwrap - Laravel Bundles. It's a beautiful way to use powerful Linux/Unix tools in PHP.

Shellwrap - Laravel Bundles

Easily and logically pipe commands together, capture errors as PHP Exceptions and use a simple yet powerful syntax. Works with any command line tool automagically. Flexible and sexy syntax.Exceptions are thrown if the executable returns an error.Paths to binaries are automatically resolved.All arguments are properly escaped.

Install php artisan bundle:install shellwrap Open bundles.php 'shellwrap' => array( auto => true ) Examples Acknowledgements Inspired by the Python project sh by Andrew Moffat Original source ShellwrapMrRio/shellwrap Stats Watchers: Forks: Ratings: 1 likes Installs: 470. Testing Laravel Controllers. Testing controllers isn't the easiest thing in the world.

Testing Laravel Controllers

Well, let me rephrase that: testing them is a cinch; what's difficult, at least at first, is determining what to test. Should a controller test verify text on the page? Should it touch the database? Should it ensure that variables exist in the view? If this is your first hay-ride, these things can be confusing! Controller tests should verify responses, ensure that the correct database access methods are triggered, and assert that the appropriate instance variables are sent to the view. The process of testing a controller can be divided into three pieces. Isolate: Mock all dependencies (perhaps excluding the View).Call: Trigger the desired controller method.Ensure: Perform assertions, verifying that the stage has been set properly.

The Hello World of Controller Testing The best way to learn these things is through examples. In the code snippet above, we make a GET request to /posts, or localhost:8000/posts. Overloading is Your Friend. Laravel 4: A Start at a RESTful API. RESTful API's are hard!

Laravel 4: A Start at a RESTful API

There are a lot of aspects to designing and writing a successful one. For instance, some of the topics that you may find yourself handling include authentication, hypermedia/HATEOS, versioning, rate limits, and content negotiation. Rather than tackling all of these concepts, however, let's instead focus on the basics of REST.

We'll make some JSON endpoints behind a basic authentication system, and learn a few Laravel 4 tricks in the process. Let's build an API for a simple Read-It-Later app. Create a new install of Laravel 4. We're going to first create an encryption key for secure password hashing. Alternatively, you can simple edit your app/config/app.php encryption key: Once you have a working install of Laravel 4, we can get started with the fun. This will only require two database tables: Users, including a username and passwordURLs, including a url and description We'll use Laravel's migrations to create and populate the database.

Let's test this out. Cool! Shellwrap - Laravel Bundles. Laravel Tips - Tricks - Workarounds For Beginners - Aj freelancer. I’ve been working with Laravel for a few weeks now and have encountered a bunch of interesting problems/confusions that are not explicitly explained anywhere.

Laravel Tips - Tricks - Workarounds For Beginners - Aj freelancer

Well, either that, or I just overlooked it easily. Hope this helps you! I noted some common errors and overlooks. If some of it seems very elementary or basic, that’s fine. The way I compiled this list was by watching what I googled, what problems I had and others had, and put my solution/answer here. Pretty URLs To enable pretty URLs, all you need to do is go to your application/config/application.php file, look for Application Index and erase the “index.php” between the quotes (leave empty quotes). <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} ! If THAT doesn’t work, you might need some extra help that I can’t provide Changed your ‘key’ and now you’re getting an error?

Getting an error, something about “unserialize”: unserialize() [function.unserialize]: Error at offset 0 of 224 bytes Spot on? Sweet. Why?