Download the PHP package ar7/media without Composer

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

Media - Explore, Upload, Delete and Create new folder

You can use this package to upload your media and attach the media to your models.

Version Laravel
^1.0.0 ^10.7

Installation

  1. composer require ar7/media.
  2. add Ar7\Media\MediaServiceProvider::class to providers array inside config/app.php.
  3. add 'Ar7Media' => Ar7\Media\Facades\Ar7Media::class to aliases array inside config/app.php.
  4. add "Ar7\\Media\\": "vendor/ar7/media/src/" to autoload => psr-4 object inside composer.json file, then run this command: composer dump-autoload.
  5. If you haven't link your storage, please run this command php artisan storage:link.
  6. run php artisan vendor:publish --tag=ar7-media-config to copy the config file into config folder.
  7. run php artisan vendor:publish --tag=ar7-media-public to copy asset files into public folder, running this command with --force flag is recommended.
  8. run php artisan vendor:publish --tag=ar7-media-migrations to copy the migrations into database/migrations folder.
  9. run php artisan migrate to create the tables.

API

You can use these methods on your model:

Method Parameters Description Example
addMedia $paths - (Single-Array) Add media to your model User::findOrFail(1)->addMedia([$request->input('image')])
updateMedia $paths - (Array) Update media for your model User::findOrFail(1)->updateMedia([$request->input('image')])
removeMedia $name - (Single-Array) Remove media from your model User::findOrFail(1)->removeMedia('image')
getMedia - Return all the media for your model $media = User::findOrFail(1)->getMedia()
getMediaByName $pattern (String) Return all the media that has a name with the provided pattern $media = User::findOrFail(1)->getMediaByName('/(extra_images)/')
getMedium $id - (Integer) Get a single medium of your model with an id, If id is empty it will return the first medium $medium = User::findOrFail(1)->getMedium(2)
getMediumByName $name - (Single-Array) Get a single medium of your model with the name, If the name is empty it will return the first medium $medium = User::findOrFail(1)->getMediumByName('image')

There is a getSubSize method for a single medium which you can get a specific subSize (that you defined in the config file) of an image, using below code:

Usage

First, take A look at the ar7_media.php file in config folder.

Add Ar7Media to your model

In your view you have to load the css and js files and load the media selector:

Example:

The @ar7_media_file directive has two parameters:

  1. ID - for the media selector
  2. OPTIONS - A JSON object with these keys:

Upload from controller

To upload a file from controller simply use the Ar7Media facade.

Load with JS

If you want to load the selector with javascript use the instruction below:

add this inside or outside the media selector blade directives.

then load the selector with this code

The parameters of loadMediaSelectorWithJS method are exactly like @ar7_media_file directive. It only has a third parameter that get true or false. you should pass false if you want to add that div element outside the media selector blade directives.

Integrations

CKEditor

In your view add a textarea:

Use media as CKEditor file browser:


All versions of media with dependencies

PHP Build Version
Package Version
Requires intervention/image Version ^2.7
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 ar7/media contains the following files

Loading the files please wait ....