dev-master
9999999-dev https://github.com/fabiopaiva/FileStorageDoctrineORM Entity to store files ZF2
MIT
The Requires
- php >=5.3.3
- doctrine/doctrine-orm-module >=0.7.0
by Fábio Paiva
Wallogit.com
2017 © Pedro Peláez
DoctrineORM Entity to store files ZF2
php composer.phar require "fabiopaiva/file-storage": "dev-master"
cd vendor git clone https://github.com/fabiopaiva/FileStorage
application.config.php
<?php
return array(
'modules' => array(
'DoctrineModule',
'DoctrineORMModule',
'FileStorage',
'Application',
),
...
?>
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
mkdir public/fileStorage chmod 777 public/fileStorage
You can set another folder in your form construction, (*1)
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
In your entity:, (*3)
/**
* @ORM\ManyToOne(targetEntity="\FileStorage\Entity\Document", cascade={"persist", "remove"})
* @var \FileStorage\Entity\Document
*/
protected $myFile;
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();?>
DoctrineORM Entity to store files ZF2
MIT