PHP code example of yangweijie / filesystem-ctfile
1. Go to this page and download the library: Download yangweijie/filesystem-ctfile 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/ */
yangweijie / filesystem-ctfile example snippets
// test-installation.php
le\CtFileAdapter;
use YangWeijie\FilesystemCtfile\CtFileClient;
use YangWeijie\FilesystemCtfile\ConfigurationManager;
echo "Testing Filesystem ctFile Extension Installation..." . PHP_EOL;
// Test 1: Check if main classes are available
$classes = [
CtFileAdapter::class,
CtFileClient::class,
ConfigurationManager::class,
];
foreach ($classes as $class) {
if (class_exists($class)) {
echo "✓ {$class} - OK" . PHP_EOL;
} else {
echo "✗ {$class} - MISSING" . PHP_EOL;
exit(1);
}
}
// Test 2: Test configuration validation
try {
$config = new ConfigurationManager([
'ctfile' => [
'host' => 'test.example.com',
'username' => 'test',
'password' => 'test',
]
]);
echo "✓ Configuration validation - OK" . PHP_EOL;
} catch (Exception $e) {
echo "✗ Configuration validation - FAILED: " . $e->getMessage() . PHP_EOL;
exit(1);
}
echo PHP_EOL . "Installation verification completed successfully!" . PHP_EOL;
echo "You can now use the filesystem-ctfile package in your project." . PHP_EOL;
use League\Flysystem\Filesystem;
use YangWeijie\FilesystemCtfile\CtFileAdapter;
// Configure the ctFile adapter
$config = [
'ctfile' => [
'host' => 'your-ctfile-host.com',
'port' => 21,
'username' => 'your-username',
'password' => 'your-password',
'ssl' => false,
'passive' => true,
],
];
// Create the adapter and filesystem
$adapter = new CtFileAdapter($config);
$filesystem = new Filesystem($adapter);
// Use standard Flysystem operations
$filesystem->write('path/to/file.txt', 'Hello, World!');
$content = $filesystem->read('path/to/file.txt');
$exists = $filesystem->fileExists('path/to/file.txt');
$filesystem->delete('path/to/file.txt');
bash
# Check available PHP versions
php --version
# If using multiple PHP versions, specify the correct one
/usr/bin/php8.1 -v
composer config platform.php 8.1.0
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.