2017 © Pedro Peláez
 

library file-storage

DoctrineORM Entity to store files ZF2

image

fabiopaiva/file-storage

DoctrineORM Entity to store files ZF2

  • Wednesday, October 29, 2014
  • by fabiopaiva1
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

FileStorage

Install

Composer

php composer.phar require "fabiopaiva/file-storage": "dev-master"

GIT

cd vendor
git clone https://github.com/fabiopaiva/FileStorage

Enable Module

application.config.php
<?php
    return array(
        'modules' => array(
        'DoctrineModule',
        'DoctrineORMModule',
        'FileStorage', 
        'Application',
),
...
?>

Create table in database

vendor/bin/doctrine-module orm:schema-tool:update --dump-sql
# copy the generated sql and execute in your database for productions environment
# or force to execute into your database directly
vendor/bin/doctrine-module orm:schema-tool:update --force

Create a writable folder

mkdir public/fileStorage
chmod 777 public/fileStorage

You can set another folder in your form construction, (*1)

Protect this folder

It's seriously recommended to protect this folder. If you are using Apache, create a file into this folder called .htaccess with the content:, (*2)

php_flag engine off
Options -indexes

Usage

In your entity:, (*3)

/**
 * @ORM\ManyToOne(targetEntity="\FileStorage\Entity\Document", cascade={"persist", "remove"})
 * @var \FileStorage\Entity\Document
 */
protected $myFile;

Helpers

use the route file-storage to manage files, (*4)

<?php echo $this->url('file-storage');?>

use the method downloadLink to get the filepath, (*5)

<?php echo $document->getDownloadLink();?>

The Versions

29/10 2014

dev-master

9999999-dev https://github.com/fabiopaiva/FileStorage

DoctrineORM Entity to store files ZF2

  Sources   Download

MIT

The Requires