Download the PHP package tinkeshwar/imager without Composer

On this page you can find all versions of the php package tinkeshwar/imager. 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 imager

Documentation

Installation

Use the command below to install this package to your existing laravel project.

composer require tinkeshwar/imager

After successfull installation publish the config file using one of the following commands:

Install Automatically

php artisan imager:install

Install Manually

php artisan vendor:publish

and select Tinkeshwar\Imager\ImagerServiceProvider this will copy image.php into your app/config.

Run

php artisan migrate

To migrate the image table schema into you database.

Run below command to create symbolic link

php artisan storage:link

Usage

Your model
<?php
namespace  App\Models;
use Illuminate\Database\Eloquent\Model;
use Tinkeshwar\Imager\Models\Image;

class <YOUR MODEL>  extends  Model{

    /**
    * One to One Relation with <YOUR> Model
    * A <YOUR MODEL> has one image
    */
    public  function  image(){
        return  $this->morphOne(Image::class,'imageable');
    }

    /**
    * One to Many Relation with <YOUR> Model
    * A <YOUR MODEL> has many images
    */
    public  function  images(){
        return  $this->morphMany(Image::class,'imageable');
    }
}
Your controller
<?php

namespace  App\Http\Controllers;

use App\Models\<YOUR MODEL>;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Tinkeshwar\Imager\Imager;

class  <YOUR CONTROLLER>  extends  Controller {

    public function store (Request $request){
        $data = $request->validate([
            'name'=>'required',
            'image'=>'image|nullable'
        ]);
        $yourmodel = <YOUR MODEL>::create($data);
        if($request->hasFile('image')){
            $yourmodel->image()->create([
                'name'=>Imager::moveFile($request->file('image'),'public'), //second parameter is optional, `public` is default
                'path'=>'public/', //sample path used in above function
                'driver' => config('image.image_storage')
            ]);
        }
    }

    public function destroy ($imageId){
        Imager::deleteFile($imageId);
    }
}
Your view
<form  action="<your route>"  method="POST"  enctype="multipart/form-data">
    @csrf
    <div  class="form-group">
        <label >Example file input</label>
        <input  type="file"  class="form-control-file"  name="image">
    </div>
    <button  type="submit"  class="btn btn-primary">Submit</button>
</form>
Static image usage on blade
{{thumb($source, $height, $width, $extension)}}
Parameter Usage
$source path/to/image/in/public/folder
$height number
$width number
$extension optional :: default: .webp allowed: .webp, .png, .jpg

example

<img src={{thumb('/image/bg.png', 100, 100)}}/>

Dynamic image usage on blade

Once the file has been uploaded into the system, it can be access with

<Your Host>/thumb/{image_id}/{height}/{width}

example

http://localhost:8000/thumb/1/100/100

If an image exists in cache for provided image_id and aspect ratio it will display existing image. If not, it will generate an image with the required aspect ratio at the storage defined in config/image.php

NOTE:

If an image is re-uploaded and previous copy of image still exists in cache, then the new image wouldn't be cached, you would need to clear cache of previous image for the new one to take it's place.

There are two options to clear the cache:

  1. By artisan command php artisan imager:clear
  2. By calling following facade method Imager::listCache()

All versions of imager with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
ext-gd Version *
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 tinkeshwar/imager contains the following files

Loading the files please wait ....