1. Go to this page and download the library: Download gregpriday/gitignore-php 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/ */
gregpriday / gitignore-php example snippets
regPriday\GitIgnore\GitIgnoreManager;
use Symfony\Component\Finder\SplFileInfo;
// Create a GitIgnoreManager instance for your project directory
$manager = new GitIgnoreManager('/path/to/your/project');
// Check a specific file using Symfony's SplFileInfo
$file = new SplFileInfo('/path/to/your/project/src/Example.php', 'src', 'src/Example.php');
if ($manager->accept($file)) {
echo "File is not ignored.\n";
} else {
echo "File is ignored.\n";
}
use GregPriday\GitIgnore\GitIgnoreManager;
// Load the default .gitignore and add .ctreeignore as an extra ignore file.
$manager = new GitIgnoreManager('/path/to/your/project', true, ['.ctreeignore']);
use GregPriday\GitIgnore\PatternConverter;
$converter = new PatternConverter();
$expanded = $converter->expandBraces('*.{js,css,html}');
// Expected output: ['*.js', '*.css', '*.html']
print_r($expanded);
use GregPriday\GitIgnore\GitIgnoreManager;
use Symfony\Component\Finder\Finder;
$projectPath = '/path/to/your/git/repo';
$manager = new GitIgnoreManager($projectPath);
$finder = new Finder();
$finder->files()->in($projectPath);
$acceptedFiles = [];
foreach ($finder as $file) {
if ($manager->accept($file)) {
$acceptedFiles[] = $file->getRelativePathname();
}
}
echo "Accepted files:\n";
print_r($acceptedFiles);
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.