Skip to content

Introducing Cloudinary’s New Laravel SDK

Known far and wide as the “PHP framework for web artisans,” Laravel is a robust, expressive, and productive developer tool. In particular, it’s clean, smooth, and fluent API interface greatly simplifies the process of embedding features in web apps.

Since its release in June 2011 by Taylor Otwell, a .NET developer turned PHP programmer, Laravel has garnered massive growth in usage, accolades, and largely positive critique from developers. As of now, Laravel has earned over 60,000 stars on GitHub with a total download of over 98 million. That’s a big deal!

laravel stats

Below are GitHub’s download statistics of five popular web frameworks tailored for trendy server-side programming languages:

No matter that those are vanity metrics, they undeniably illustrate the efficacy and reliability of Laravel’s superior developer experience.

This article shows the benefits and capabilities of the Laravel PHP framework and the way to upload to and transform files with Cloudinary with its new Laravel SDK. Here are the topics:

As do many other web frameworks, Laravel follows the Model-View-Controller pattern but also provides a Facade pattern, which accords access to several core capabilities. All that translates to an intuitive and fast start for you as developers. You’ll find yourself automatically memorizing the classes to import for various tasks.

Example: The facades below are interfaces for all major features, such as authentication, mail, notifications, caching, and file upload.

Facade Classes
App Illuminate\Support\Facades\App::class,
Arr Illuminate\Support\Arr::class,
Artisan Illuminate\Support\Facades\Artisan::class,
Auth Illuminate\Support\Facades\Auth::class,
Blade Illuminate\Support\Facades\Blade::class,
Broadcast Illuminate\Support\Facades\Broadcast::class,
Bus Illuminate\Support\Facades\Bus::class,
Cache Illuminate\Support\Facades\Cache::class,
Config Illuminate\Support\Facades\Config::class,
Cookie Illuminate\Support\Facades\Cookie::class,
Crypt Illuminate\Support\Facades\Crypt::class,
DB Illuminate\Support\Facades\DB::class,
Eloquent Illuminate\Database\Eloquent\Model::class,
Event Illuminate\Support\Facades\Event::class,

Here are more details.

Laravel makes available through abstraction the many similar building blocks required by web apps, freeing up developers to focus on business logic. Impressively, almost everything in Laravel is preconfigured out of the box.

Laravel offers authentication and authorization capabilities. To configure authentication for your app while installing Laravel, type:

laravel new app --auth
Code language: JavaScript (javascript)

That command line readies all the scaffolding you need for authentication to work. You can then customize it as desired by following the procedures in the documentation.

You must have tackled caching logic and strategies, headaches both, multiple times. The twists and turns involved in bursting caches and setting up the right storage are constant challenges.

Laravel comes with a caching capability along with drivers and integrations for Redis, Memcached, database, files, etc. Simply opt in and out of the drivers you would like to use from the environment file. Additionally, you can leverage the Cache facade and helper function for caching apps in your code base.

Blade, an unobtrusive templating engine, is available in Laravel. To fully take advantage of that engine, ensure that your view files end with the .blade.php extension.

You can write plain PHP code along with the default Blade syntax and components. Plus, caching is guaranteed with Blade, ensuring fast views for Laravel apps. Here’s an example of a Blade view:

        <div class="flex-center position-ref full-height">
            @if (Route::has('login'))
                <div class="top-right links">
                        <a href="{{ url('/home') }}">Home</a>
                        <a href="{{ route('login') }}">Login</a>

                        @if (Route::has('register'))
                            <a href="{{ route('register') }}">Register</a>

            <div class="content">
                <div class="title m-b-md">
Code language: HTML, XML (xml)

Building jobs and queues are a chore for novice developers. Even experienced programmers find those tasks laborious, let alone that the tasks might not work as expected. However, jobs can fail and, when they do, you must know when, how, and why, and ensure that they automatically retry.

The effective integration of jobs and queues in Laravel follows the convention over configuration paradigm. Just be sure to set up your workers and crontab files on the hosting platform. If you can’t do that, Laravel’s premier Forge hosting platform does it for you by default.

Forge, which currently hosts and manages over 330,000 web apps, is proven to be trustworthy and effective.

Over 80 percent of web apps interact with a database, which requires SQL code for adding, updating, fetching, and deleting data from there. As web apps grow in size and complexity, so does the difficulty of writing and maintaining queries—exponentially. That means you must learn the multitude of SQL functions and query operations, which is hardly something to relish.

No need to do that with Laravel, however, which liberates you to work on tasks like business logic. Laravel’s built-in Eloquent ORM abstracts SQL away with reusable classes, functions, and relationship mechanisms—all the tools you need for performing intricate queries in your app.

To me, Laravel’s developer community is the best out there, always helpful and supportive of other members. Below are the learning resources and packages Laravel’s developer community has built over the years.

  • Laracasts, a website that teaches you everything about Laravel.
  • Laravel IO, a community portal for problem solving and knowledge sharing among Laravel enthusiasts.
  • Laravel Daily, a website in which myriad tips and tricks are shared.
  • Packages and tools for integrating remarkable features outside the Laravel core into web apps. Popular examples are Graham Campbell, Spatie, Beyondcode, Jeffrey Way, and Taylor Otwell.

You can build all web apps with Laravel: from one-page sites to content management systems (CMS) to forums, to e-commerce stores. Go to made with Laravel for a host of examples of apps and websites developed with Laravel.

The article Twenty-Five Popular Applications Built With Laravel is another informative reference.

Laravel’s file system leverages the useful PHP Flysystem on GitHub along with an Amazon S3 and a local file-driver storage. Many Laravel developers have built drivers for external storage services.

With the newly released Laravel SDK from Cloudinary, you can efficiently upload, manipulate, optimize, and deliver files. For example, to upload and transform media files, code like this:

 // Store the image on Cloudinary and return the secure URL
Code language: PHP (php)

Upload Files

// Store the uploaded file in the "alarmanda" directory on Cloudinary
 $request->file('image')->store('alarmanda', 'cloudinary');
Code language: PHP (php)

Upload Files to a Specific Directory

                $request->file('image')->getRealPath(), [
                'transformation' => [
                    'gravity' => 'auto',
                    'width' => 300,
                    'height' => 300,
                    'crop' => 'crop'
Code language: PHP (php)

Upload and Transform a File Simultaneously

You can perform numerous other tasks with Cloudinary’s Laravel SDK: retrieving and displaying media in your app, attaching media to existing models, interacting with files on the console. Furthermore, the SDK contains helpful Blade UI components, ready for deployment.

Back to top

Featured Post