PHP code example of nishthatechnosoft / php-file-manager
1. Go to this page and download the library: Download nishthatechnosoft/php-file-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nishthatechnosoft / php-file-manager example snippets
use Dhiraj\PhpFileManager\FileManager;
use Dhiraj\PhpFileManager\Resources\ResourceManager;
$fileManager = new FileManager($config);
$resourceManager = $fileManager->getResourceManager();
// Get CSS content for custom styling
$css = $resourceManager->getCssContent();
// Get JavaScript for custom integration
$js = $resourceManager->getJsContent();
// In a Laravel controller
public function fileManager()
{
$config = config('filemanager');
$fileManager = new \Dhiraj\PhpFileManager\FileManager($config);
ob_start();
$fileManager->run();
$output = ob_get_clean();
return response($output);
}
// In a Symfony controller
use Dhiraj\PhpFileManager\FileManager;
use Symfony\Component\HttpFoundation\Response;
public function fileManager(): Response
{
$config = $this->getParameter('filemanager');
$fileManager = new FileManager($config);
ob_start();
$fileManager->run();
$content = ob_get_clean();
return new Response($content);
}
Dhiraj\PhpFileManager\FileManager;
// Create file manager instance
$fileManager = new FileManager([
'root_path' => '/path/to/your/files',
'password' => 'your-secure-password'
]);
// Run the application
$fileManager->run();
public function run(): void // Run the application
public function getConfig(): Configuration // Get configuration instance
public function getAuth(): AuthenticationService // Get auth service
public function getSecurity(): SecurityService // Get security service
public function getFileController(): FileController // Get file controller
public function get(string $key, mixed $default = null): mixed
public function set(string $key, mixed $value): void
public function getRootPath(): string
public function getMaxFileSize(): int
public function getAllowedExtensions(): array
public function isExtensionAllowed(string $filename): bool
public function createFile(string $filename, string $dir): void
public function createFolder(string $foldername, string $dir): void
public function deleteItem(string $item, string $dir): void
public function renameItem(string $oldName, string $newName, string $dir): void
public function copyItem(string $item, string $destination, string $currentDir): void
public function moveItem(string $item, string $destination, string $currentDir): void
public function bulkDelete(array $items, string $dir): void
public function bulkCopy(array $items, string $destination, string $currentDir): void
public function bulkMove(array $items, string $destination, string $currentDir): void
public function createArchiveWithName(string $archiveName, array $items, string $dir): void
public function unarchiveFile(string $archiveFile, string $dir): void
public function unarchiveToPath(string $archiveFile, string $destination, string $conflictResolution, string $currentDir): void
bash
composer
bash
git clone https://github.com/dhiraj-nishthatechnosoft/php-file-manager.git
cd php-file-manager
composer install
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.