Filelib is a file library for PHP. See the wiki for more documentation.
- PHP 5.3.x
- A database for storing metadata like
MySQL
,PostgreSQL
,SQLite
orMongoDB
Filelib must have a place to store both files and file metadata.
- Use a database schema from
/docs/
to initialize your database tables.
For MySQL
mysql -uroot -p filelib_example < schema-mysql.sql
- Configure Filelib with directory paths for
private
andpublic
and make them writable by the web server.
<?php
use Xi\Filelib\FileLibrary;
use Xi\Filelib\Storage\FilesystemStorage;
use Xi\Filelib\Backend\Platform\DoctrineOrmPlatform;
use Xi\Filelib\Publisher\Filesystem\SymlinkFilesystemPublisher;
/**
* @var $entityManager Doctrine\ORM\EntityManager
*/
$filelib = new FileLibrary(
new FilesystemStorage('/path/to/my/application/data/private'),
new DoctrineOrmPlatform($entityManager),
new SymlinkFilesystemPublisher('/path/to/my/application/web/files', '/files')
);
$file = $filelib->upload('/path/to/some/file.jpg');
For integration, see:
Explaining the mandatory subsystems:
Virtual filesystem with folders and files.
- ACL handles ACL
- Backend / Platform handles metadata storage
- Publisher publishes
- Storage stores physical files