Download the PHP package expstudio/laraclip without Composer

On this page you can find all versions of the php package expstudio/laraclip. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laraclip

LaraClip

Attachment upload package for Laravel 4 with PHP5.3.x support.

Start version - v0.1.0

LaraClip was downgrade from Codesleeve/Stapler by Watee Wichiennit.

Requirements

LaraClip currently requires php >= 5.3 (LaraClip is take out traits and go back to normal class inheritance).

Installation

LaraClip is distributed as a composer package, which is how it should be used in your app.

Install the package using Composer. Edit your project's composer.json file to require expstudio/laraclip.

Once this operation completes, the final step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.

Warning

Do not use new PHP5.4+ array syntax ([] square bracket). Use old style array ( array() ) instead.

Quickstart

In the document root of your application (most likely the public folder), create a folder named system and grant your application write permissions to it.

In your model:

Make sure that the hasAttachedFile() method is called right before parent::__construct() of your model.

From the command line, use the migration generator:

In your new view:

In your controller:

In your show view:

To detach (reset) a file, simply call the clear() method of the attachment attribute before saving (you may also assign the constant LARACLIP_NULL):

or

This will ensure the the corresponding attachment fields in the database table record are cleared and the current file is removed from storage. The database table record itself will not be destroyed and can be used normally (or even assigned a new file upload) as needed.

Overview

LaraClip works by attaching file uploads to database table records. This is done by defining attachments inside the table's corresponding model and then assigning uploaded files (from your forms) as properties (named after the attachments) on the model before saving it. In essence, this allows uloaded files to be treated just like any other property on the model; laraclip will abstract away all of the file processing, storage, etc so you can focus on the rest of your project without having to worry about where your files are at or how to retrieve them.

A model can have multiple attachments defined (avatar, photo, foo, etc) and in turn each attachment can have multiple sizes (styles) defined. When an image or file is uploaded, LaraClip will handle all the file processing (moving, resizing, etc) and provide an attachment object (as a model property) with methods for working with the uploaded file. To accomplish this, four fields (named after the attachemnt) will need to be created (via laraclip:fasten or manually) in the corresponding table for any model containing a file attachment. For example, for an attachment named 'avatar' defined inside a model named 'User', the following fields would need to be added to the 'users' table:

Inside your table migration file, something like this should suffice:

Configuration

Configuration is available on both a per attachment basis or globally through the configuration file settings. LaraClip is very flexible about how it processes configuration; global configuration options can be overriden on a per attachment basis so tha you can easily cascade settings you would like to have on all attachments while still having the freedom to customize an individual attachment's configuration. To get started, the first thing you'll probably want to do is publish the default configuration options to your app/config directory.

Having done this, you should now be able to configure LaraClip however you see fit wihout fear of future updates overriding your configuration files.

LaraClip-Configuration

The following configuration settings apply to laraclip in general.

Default values:

Filesystem-Storage-Configuration

Filesystem (local disk) is the default storage option for laraclip. When using it, the following configuration settings are available:

Default values:

S3-Storage-Configuration

As your web application grows, you may find yourself in need of more robust file storage than what's provided by the local filesystem (e.g you're using multiple server instances and need a shared location for storing/accessing uploaded file assets). LaraClip provides a simple mechanism for easily storing and retreiving file objects with Amazon Simple Storage Service (Amazon S3). In fact, aside from a few extra configuration settings, there's really no difference between s3 storage and filesystem storage when interacting with your attachments. To get started with s3 storage you'll first need to add the AWS SDK to your composer.json file:

Next, change the storage setting in config/laraclip.php from 'filesystem' to 's3' (keep in mind, this can be done per attachment if you want to use s3 for a specific attachment only). After that's done, crack open config/s3.php for a list of s3 storage settings:

Default values:

Interpolations

With LaraClip, uploaded files are accessed by configuring/defining path, url, and default_url strings which point to you uploaded file assets. This is done via string interpolations. Currently, the following interpolations are available for use:

Image-Processing

LaraClip makes use of the imagine image library for all image processing. Out of the box, the following image processing patterns/directives will be recognized when defining LaraClip styles:

To create styles for an attachment, simply define them (you may use any style name you like: foo, bar, baz, etc) inside the attachment's styles array using a combination of the directives defined above:

``

For more customized image processing you may also pass a callable type as the value for a given style definition. LaraClip will automatically inject in the uploaded file object instance as well as the Imagine\Image\ImagineInterface object instance for you to work with. When you're done with your processing, simply return an instance of Imagine\Image\ImageInterface from the callable. Using a callable for a style definition provides an incredibly amount of flexibilty when it comes to image processing. As an example of this, let's create a watermarked image using a closure (we'll do a smidge of image processing with Imagine):

``

Examples

Create an attachment named 'picture', with both thumbnail (100x100) and large (300x300) styles, using custom url and default_url configurations.

Create an attachment named 'picture', with both thumbnail (100x100) and large (300x300) styles, using custom url and default_url configurations, with the keep_old_files flag set to true (so that older file uploads aren't deleted from the file system) and image cropping turned on.

To store this on s3, you'll need to set a few s3 specific configuraiton options (the url interpolation will no longer be necessary when using s3 storage):

LaraClip makes it easy to manage multiple file uploads as well. In laraclip, attachments (and the uploaded file objects they represent) are tied directly to database records. Because of this, processing multiple file uploades is simply a matter of defining the correct Eloquent relationships between models.

As an example of how this works, let's assume that we have a system where users need to have multiple profile pictures (let's say 3). Also, let's assume that users need to have the ability to upload all three of their photos from the user creation form. To do this, we'll need two tables (users and profile_pictures) and we'll need to set their relationships such that profile pictures belong to a user and a user has many profile pictures. By doing this, uploaded images can be attached to the ProfilePicture model and instances of the User model can in turn access the uploaded files via their hasMany relationship to the ProfilePicture model. Here's what this looks like:

In models/user.php:

In models/ProfilePicture.php:

In the user create view:

In controllers/UsersController.php

Displaying uploaded files is also easy. When working with a model instance, each attachment can be accessed as a property on the model. An attachment object provides methods for seamlessly accessing the properties, paths, and urls of the underlying uploaded file object. As an example, for an attachment named 'photo', the path(), url(), createdAt(), contentType(), size(), and originalFilename() methods would be available on the model to which the file was attached. Continuing our example from above, we can loop through a user's profile pictures display each of the uploaded files like this:

We can also retrieve the file path, size, original filename, etc of an uploaded file:

Fetching-Remote-Images

As of LaraClip v1.0.0-Beta4, remote images can now be fetched by assigning an absolute URL to an attachment property that's defined on a model:

This is very useful when working with third party API's such as facebook, twitter, etc. Note that this feature requires that the CURL extension is included as part of your PHP installation.

Advanced-Usage

When working with attachments, there may come a point where you wish to do things outside of the normal workflow. For example, suppose you wish to clear out an attachment (empty the attachment fields in the underlying table record and remove the uploaded file from storage) without having to destroy the record itself. As mentioned above, you can always set the attachment attribute to LARACLIP_NULL on the record before saving, however this only works if you save the record itself afterwards. In situations where you wish to clear the uploaded file from storage without saving the record, you can use the attachment's destroy method:

You may also reprocess uploaded images on an attachment by calling the reprocess() command (this is very useful for adding new styles to an existing attachment type where records have already been uploaded).

This may also be achieved via a call to the laraclip:refresh command.

Reprocess all attachments for the ProfilePicture model: php artisan laraclip:refresh ProfilePicture

Reprocess only the photo attachment on the ProfilePicture model: php artisan laraclip:refresh TestPhoto --attachments="photo"

Reprocess a list of attachments on the ProfilePicture model: php artisan laraclip:refresh TestPhoto --attachments="foo, bar, baz, etc"


All versions of laraclip with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
imagine/imagine Version ~0.5.0
laravel/framework Version ~4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package expstudio/laraclip contains the following files

Loading the files please wait ....