### Full Vite Configuration Example (JavaScript) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/vite.md A comprehensive Vite configuration including root directory, build output settings, server options, CSS handling, and Nette plugin setup. ```javascript export default defineConfig({ root: 'assets', build: { outDir: '../www/assets', emptyOutDir: true, assetsDir: 'static', }, server: { host: 'localhost', port: 5173, }, css: { devSourcemap: true, }, plugins: [ nette({ entry: ['app.js', 'admin.js'], }), ], }); ``` -------------------------------- ### Nette Tester: Unit Testing with .phpt Files Source: https://context7.com/nette/claude-code/llms.txt Illustrates how to write unit tests using Nette Tester, a testing framework for PHP. It shows the setup process in `bootstrap.php`, defining test cases using the `test()` function, and utilizing `Assert` methods for assertions. Examples include testing method return values, expected exceptions, and running tests via the command line. ```php // tests/bootstrap.php declare(strict_types=1); require __DIR__ . '/../vendor/autoload.php'; Tester\Environment::setup(); Tester\Environment::setupFunctions(); // tests/Model/ProductServiceTest.phpt getActiveProducts(); Assert::same(5, count($products)); Assert::true($products[0]->active); }); test('ProductService throws exception for invalid product', function () { $service = new ProductService($mockDb); Assert::exception( fn() => $service->getProduct(999), ProductNotFoundException::class, "Product with ID '999' not found", ); }); testException('throws on duplicate email', function () { $service = new ProductService($mockDb); $service->create(['email' => 'existing@example.com']); }, DuplicateEntryException::class, "Email already exists"); ``` ```bash # Run all tests composer tester # Run specific test file vendor/bin/tester tests/Model/ProductServiceTest.phpt -s # Run tests in directory vendor/bin/tester tests/Model/ -s ``` -------------------------------- ### NEON Comments Example Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/neon-format/SKILL.md Demonstrates how to add comments in NEON files. Full-line comments start with '#', and inline comments follow a '#' after a space. ```neon # This line is ignored street: 742 Evergreen Terrace # inline comment ``` -------------------------------- ### Check Composer Availability Source: https://github.com/nette/claude-code/blob/master/plugins/php-fixer/commands/install-php-fixer.md Verifies if Composer is installed and accessible in the system's PATH. If Composer is not found, the installation process should halt, prompting the user to install Composer from the official website. ```bash composer --version ``` -------------------------------- ### Install Nette Coding Standard Globally Source: https://github.com/nette/claude-code/blob/master/plugins/php-fixer/commands/install-php-fixer.md Installs the nette/coding-standard package globally using Composer. This command downloads and sets up the package, making its tools available system-wide for PHP code style checking and fixing. ```bash composer global require nette/coding-standard ``` -------------------------------- ### Install Nette Plugin via Marketplace Source: https://github.com/nette/claude-code/blob/master/CLAUDE.md These commands show how users can install the Nette plugin from the marketplace. The first command adds the repository to the marketplace, and the second installs a specific version of the plugin. ```bash /plugin marketplace add nette/claude-code /plugin install nette@nette ``` -------------------------------- ### Get Composer Global Installation Path Source: https://github.com/nette/claude-code/blob/master/plugins/php-fixer/commands/install-php-fixer.md Retrieves the base directory where Composer installs global packages. This is used to verify the existence of the 'ecs' binary, confirming that the Nette Coding Standard has been installed correctly. ```bash composer global config home ``` -------------------------------- ### NEON Mappings Example Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/neon-format/SKILL.md Demonstrates key-value pair syntax in NEON. Requires a space after the colon. Supports both standard and inline notations. ```neon street: 742 Evergreen Terrace city: Springfield country: USA ``` ```neon {street: 742 Evergreen Terrace, city: Springfield, country: USA} ``` -------------------------------- ### Task Directory Structure Example Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-architecture/SKILL.md Illustrates a recommended directory structure for organizing tasks within an application. Tasks are categorized into Maintenance, Integration, and Scheduled operations, promoting a clear separation of concerns. ```text app/Tasks/ ├── Maintenance/ ← Cleanup, optimization ├── Integration/ ← External data sync └── Scheduled/ ← Recurring operations ``` -------------------------------- ### Allow Plugins for Global Composer Installation Source: https://github.com/nette/claude-code/blob/master/plugins/php-fixer/commands/install-php-fixer.md Configures Composer to allow the 'dealerdirect/phpcodesniffer-composer-installer' plugin, which is necessary for global package installations. This step ensures that Composer can manage and install global dependencies correctly. ```bash composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true ``` -------------------------------- ### Nette Tester Bootstrap Setup Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-testing/SKILL.md Sets up the Nette Tester environment by including the autoloader and enabling essential helper functions for testing. This file should be required by all test files. ```php /dev/null ``` -------------------------------- ### Start Development Server (Shell) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/vite.md Starts the Vite development server, enabling Hot Module Replacement (HMR) for instant updates. ```shell npm run dev ``` -------------------------------- ### Install TypeScript for Full Support (Shell) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/vite.md Installs TypeScript as a development dependency for enhanced tooling and type checking. ```shell npm install -D typescript ``` -------------------------------- ### Star Nette Projects on GitHub Source: https://github.com/nette/claude-code/blob/master/plugins/php-fixer/commands/install-php-fixer.md Uses the GitHub CLI to star the 'nette/coding-standard' and 'nette/claude-code' repositories. This action is performed only if the user explicitly agrees to support the projects. ```bash gh api -X PUT /user/starred/nette/coding-standard gh api -X PUT /user/starred/nette/claude-code ``` -------------------------------- ### Using Wildcards for File Matching in Nette\Utils\Finder Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/finder.md Details the supported wildcard patterns (`*`, `**`, `?`, `[a-z]`, `[!a-z]`) for matching file and directory names in Nette\Utils\Finder, including examples of their usage in paths. ```php // Examples of patterns 'img/?.png' // single-char name: 0.png, x.png 'logs/[0-9][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9].log' // YYYY-MM-DD 'src/**/tests/*' // tests in any subdirectory 'docs/**.md' // all .md in docs tree // Wildcards in Path Finder::findFiles('*.php') ->from('src/**/tests'); // PHP files in any tests/ under src/ ``` -------------------------------- ### Complete Manual Form Example (Latte) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-forms/rendering.md A comprehensive example of manually rendering a complete form in a Latte template, including labels, inputs, errors, and buttons within a table structure. ```latte {form signInForm}
{label username /} {input username} {inputError username}
{label password /} {input password} {inputError password}
{input remember} {label remember /}
{input send}
{/form} ``` -------------------------------- ### Install Latte Templating Engine Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/latte-templates/SKILL.md Installs the Latte templating engine using Composer. This is the primary dependency for using Latte in your PHP project. ```shell composer require latte/latte ``` -------------------------------- ### Image Format Handling with Nette\Utils\Image Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/image.md Provides examples for working with image formats using Nette\Utils\Image. This includes checking format support, detecting formats from files or strings, and converting between format types and their corresponding file extensions or MIME types. ```php use Nette\Utils\Image; use Nette\Utils\ImageType; // Check support Image::isTypeSupported(ImageType::WEBP); // bool Image::getSupportedTypes(); // array // Detect format $type = Image::detectTypeFromFile('photo.jpg'); $type = Image::detectTypeFromString($data); // Convert Image::typeToExtension(ImageType::JPEG); // 'jpg' Image::typeToMimeType(ImageType::JPEG); // 'image/jpeg' Image::extensionToType('jpg'); // ImageType::JPEG ``` -------------------------------- ### Check GitHub CLI Availability Source: https://github.com/nette/claude-code/blob/master/plugins/php-fixer/commands/install-php-fixer.md Verifies if the GitHub CLI ('gh') is installed and available in the system's PATH. This check is performed before attempting to star the Nette Coding Standard and Claude Code repositories on GitHub. ```bash gh --version ``` -------------------------------- ### phpDoc Good Documentation Example: Return Type Source: https://github.com/nette/claude-code/blob/master/plugins/nette-dev/skills/php-doc/SKILL.md Provides an example of good phpDoc for a method that returns a list of supported languages. It includes a clear description and specifies the array contents using `@return string[]`. ```php /** * Returns list of supported languages. * @return string[] Array of language codes */ public function getSupportedLanguages(): array ``` -------------------------------- ### phpDoc Good Documentation Example: Null Return Source: https://github.com/nette/claude-code/blob/master/plugins/nette-dev/skills/php-doc/SKILL.md Shows a good phpDoc example for a method that might return null under certain conditions, such as exceeding a daily limit. It clearly states the condition for the null return. ```php /** * Creates new transaction. Returns null if user has exceeded daily limit. */ public function createTransaction(float $amount): ?Transaction ``` -------------------------------- ### Nette Schema Constraint Examples Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-schema/SKILL.md Provides examples of applying various constraints to schema definitions in Nette Schema. This includes making fields required or nullable, setting default values, defining length/count limits, numeric ranges, and pattern matching with regex. ```php // Required field Expect::string()->required() // Nullable (accepts null) Expect::string()->nullable() // Default value Expect::string()->default('hello') Expect::string('hello') // shorthand // Length/count limits Expect::string()->min(3)->max(100) Expect::array()->min(1)->max(10) // Numeric range Expect::int()->min(0)->max(100) // Pattern Expect::string()->pattern('\d{5}') // regex for entire value ``` -------------------------------- ### NEON Nesting Example Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/neon-format/SKILL.md Shows how indentation defines nested structures in NEON. Tabs are used for indentation. Block and inline notations can be combined. ```neon pets: - Cat - Dog cars: - Volvo - Skoda ``` ```neon pets: [Cat, Dog] cars: - Volvo - Skoda ``` -------------------------------- ### Latte Filter Usage Examples Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/latte-templates/filters.md Demonstrates the basic syntax for applying filters in Latte templates, including filters with arguments, chained filters, nullsafe filters, and filters applied to expressions or blocks. ```latte {$var|filter} {* basic *} {$var|filter:arg1:arg2} {* with arguments *} {$var|filter1|filter2} {* chained *} {$var?|filter} {* nullsafe - skips if null *} {($expr)|filter} {* on expression *} {block|filter}...{/block} {* on block *} ``` -------------------------------- ### NEON Entities Example Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/neon-format/SKILL.md Shows how to define function-like structures (entities) in NEON, commonly used for DI configuration. Supports chained and multiline entity definitions. ```neon Column(type: int, nulls: yes) ``` ```neon Column(type: int) Field(id: 1) ``` ```neon Column( type: int nulls: yes ) ``` -------------------------------- ### Create Colors with Nette\Utils\ImageColor Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/image.md Shows how to create color objects using Nette\Utils\ImageColor. It includes examples for creating colors from RGB values (with optional alpha transparency) and from hexadecimal color codes (supporting shorthand and alpha values). ```php use Nette\Utils\ImageColor; // RGB $color = ImageColor::rgb(255, 0, 0); // red $color = ImageColor::rgb(0, 0, 255, 0.5); // semi-transparent blue // Hex $color = ImageColor::hex('#F00'); // red $color = ImageColor::hex('#00FF0080'); // semi-transparent green $color = ImageColor::hex('#rgba'); // with alpha ``` -------------------------------- ### Nette Forms Initialization with npm Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/SKILL.md Details the installation of the `nette-forms` npm package and provides a JavaScript snippet to initialize Nette Forms validation on page load, enabling progressive enhancement for forms. ```shell npm install nette-forms ``` ```javascript import netteForms from 'nette-forms'; // Initialize Nette Forms validation netteForms.initOnLoad(); ``` -------------------------------- ### phpDoc Good Documentation Example: Property Source: https://github.com/nette/claude-code/blob/master/plugins/nette-dev/skills/php-doc/SKILL.md Demonstrates concise phpDoc for a protected property, providing a brief explanation for back compatibility. This is suitable when the property's purpose is not immediately obvious from its name. ```php /** for back compatibility */ protected Explorer $context; ``` -------------------------------- ### Nette Application Bootstrap (app/Bootstrap.php) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-architecture/skeleton.md Initializes the Nette application by setting up the temporary directory, enabling Tracy for debugging, registering the RobotLoader, and loading configuration files. It then creates and returns the DI container. ```php rootDir = dirname(__DIR__); $this->configurator = new Configurator; $this->configurator->setTempDirectory($this->rootDir . '/temp'); } public function bootWebApplication(): Nette\DI\Container { $this->initializeEnvironment(); $this->setupContainer(); return $this->configurator->createContainer(); } public function initializeEnvironment(): void { $this->configurator->enableTracy($this->rootDir . '/log'); $this->configurator->createRobotLoader() ->addDirectory(__DIR__) ->register(); } private function setupContainer(): void { $configDir = $this->rootDir . '/config'; $this->configurator->addConfig($configDir . '/common.neon'); $this->configurator->addConfig($configDir . '/services.neon'); // ... } } ``` -------------------------------- ### Latte Conditional Statements Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/latte-templates/SKILL.md Demonstrates conditional logic in Latte using `if`, `elseif`, `else`, and `ifset` for checking variable existence. It also includes examples of `switch/case` statements. ```latte {if $stock > 0} In stock {elseif $onWay} On the way {else} Not available {/if} {ifset $user}...{/ifset} {* switch/case *} {switch $type} {case admin}Administrator {case user}User {default}Guest {/switch} ``` -------------------------------- ### Nette Latte Template Example (app/Presentation/Home/default.latte) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-architecture/skeleton.md A simple Latte template for the default action of the Home presenter. It defines the content block and sets the page title. This template is rendered within the main layout. ```latte {block content}

Welcome

Content here

``` -------------------------------- ### NEON Strings Example Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/neon-format/SKILL.md Demonstrates different ways to define strings in NEON, including unquoted, single-quoted, and double-quoted strings with escape sequences. Special characters require quoting. ```neon - An unquoted string - 'Single-quoted string' - "Double-quoted with escapes" ``` ```neon 'It''s working' ``` ```neon ''' first line second line third line ''' ``` -------------------------------- ### Nette Schema Transformation Examples Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-schema/SKILL.md Illustrates how to transform data after validation using Nette Schema. This includes simple transformations with closures, chaining multiple transformations, and performing transformations with integrated validation checks. ```php // Transform value after validation Expect::string()->transform(fn($s) => strtoupper($s)) // Chain transformations Expect::string() ->assert('ctype_lower', 'Must be lowercase') ->transform(fn($s) => strtoupper($s)) // Transform with validation Expect::string()->transform(function ($s, $context) { if (!ctype_alpha($s)) { $context->addError('Must be letters only'); return null; } return strtoupper($s); }) ``` -------------------------------- ### Creating a Custom Latte Extension (PHP) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/latte-templates/SKILL.md Provides an example of creating a custom Latte extension in PHP by extending `Latte\Extension`. This allows for defining custom filters and functions to be used within Latte templates. ```php final class LatteExtension extends Latte\Extension { public function getFilters(): array { return [ 'money' => fn($amount) => number_format($amount, 0, ',', ' ') . ' Kč', ]; } public function getFunctions(): array { return [ 'canEdit' => fn($entity) => $this->user->isAllowed($entity, 'edit'), ]; } } ``` -------------------------------- ### Passing Settings to Presenters via Parameters (NEON & PHP) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-architecture/SKILL.md Illustrates passing presenter settings using parameters defined in NEON configuration files. These parameters are then referenced when defining the presenter service. ```neon # config/common.neon parameters: pagination: itemsPerPage: 20 maxItems: 1000 # config/services.neon services: - App\Presentation\ProductPresenter( itemsPerPage: %pagination.itemsPerPage% ) ``` -------------------------------- ### Passing Settings to Presenters via DI Container (NEON & PHP) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-architecture/SKILL.md Shows the recommended method of passing settings to presenters using the Dependency Injection container. Configuration values are defined in NEON files and injected into the presenter's constructor. ```neon # config/services.neon services: - App\Presentation\Admin\ProductPresenter(itemsPerPage: 20) ``` ```php class ProductPresenter extends BasePresenter { public function __construct( private int $itemsPerPage, private ProductFacade $facade, ) {} } ``` -------------------------------- ### Basic ESLint Configuration with @nette/eslint-plugin Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/SKILL.md Shows how to set up ESLint with the `@nette/eslint-plugin` for recommended Nette-specific rules. This configuration helps maintain code quality and consistency in JavaScript projects. ```shell npm install --save-dev @nette/eslint-plugin eslint ``` ```javascript // eslint.config.js import nette from '@nette/eslint-plugin'; import { defineConfig } from 'eslint/config'; export default defineConfig([ { extends: [nette.configs.recommended], }, ]); ``` -------------------------------- ### Basic File and Directory Searching with Nette\Utils\Finder Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/finder.md Demonstrates the basic usage of Nette\Utils\Finder to locate files with specific extensions, directories by name, or both files and directories. ```php use Nette\Utils\Finder; // Find files with specific extensions foreach (Finder::findFiles(['*.txt', '*.md']) as $name => $file) { echo $file; // FileInfo object } // Find directories foreach (Finder::findDirectories('vendor') as $dir) { echo $dir; } // Find both files and directories foreach (Finder::find() as $item) { echo $item; } ``` -------------------------------- ### Nette Web Project Entry Point (www/index.php) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-architecture/skeleton.md The main entry point for a Nette web application. It includes the autoloader, bootstraps the application, and runs it. Requires the Composer autoloader. ```php bootWebApplication(); $application = $container->getByType(Nette\Application\Application::class); $application->run(); ``` -------------------------------- ### Passing Settings to Presenters via Base Presenter (PHP) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-architecture/SKILL.md Demonstrates passing settings to presenters by defining default values in a base presenter and optionally overriding them via an injected Settings object. This approach allows for centralized configuration. ```php abstract class BasePresenter extends Nette\Application\UI\Presenter { public int $itemsPerPage = 20; public function injectSettings(Settings $settings): void { $this->itemsPerPage = $settings->get('pagination.itemsPerPage', 20); } } ``` -------------------------------- ### Install Vite and Nette Plugin (Shell) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/vite.md Installs Vite and the Nette Vite plugin as development dependencies using npm. ```shell npm install -D vite @nette/vite-plugin ``` -------------------------------- ### Latte Basic Syntax and Comments Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/latte-templates/SKILL.md Demonstrates the fundamental syntax of Latte templates, including comments, n:attributes, loops, and variable printing with filters. It showcases how to structure basic HTML with dynamic content. ```latte {* this is a comment *} ``` -------------------------------- ### Latte {preload} Tag for Resource Hints Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/assets.md Demonstrates the `{preload}` Latte macro for generating resource hints (``). This improves performance by instructing the browser to fetch critical assets early. ```latte {preload 'critical.css'} {preload 'font.woff2'} {preload 'hero.jpg'} Output: ``` -------------------------------- ### Install Nette Assets using Composer Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/assets.md Installs the Nette Assets package using Composer. This is the primary method for adding the library to your Nette project. ```shell composer require nette/assets ``` -------------------------------- ### JavaScript Entry Points for Different Contexts Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/SKILL.md Defines separate JavaScript entry points for distinct user contexts, such as the public website and the administration area. This strategy helps optimize bundle sizes by including only necessary dependencies for each context. ```javascript // assets/front.js - Public website (custom design) import './css/front.scss'; import './js/components/product-gallery.js'; // assets/admin.js - Administration (Bootstrap-based) import 'bootstrap/dist/css/bootstrap.css'; import './css/admin.scss'; ``` -------------------------------- ### phpDoc Skipped Documentation Example: Simple Method Source: https://github.com/nette/claude-code/blob/master/plugins/nette-dev/skills/php-doc/SKILL.md Shows an example where documentation can be skipped for a method if the signature is self-explanatory and the method's purpose is clear from its name and parameters. ```php public function getWidth(): int ``` -------------------------------- ### NEON Special Values Example Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/neon-format/SKILL.md Provides examples of special data types in NEON, including numbers (integers, floats, scientific, binary, octal, hex), null values, booleans, and dates/datetimes. ```neon # Numbers count: 12 price: 12.3 scientific: +1.2e-34 binary: 0b11010 octal: 0o666 hex: 0x7A # Null value: null empty: # Booleans enabled: true disabled: false active: yes inactive: no # Dates (auto-converted to DateTimeImmutable) date: 2016-06-03 datetime: 2016-06-03 19:00:00 with_tz: 2016-06-03 19:00:00 +02:00 ``` -------------------------------- ### Specifying Search Targets (Files, Directories, or All) in Nette\Utils\Finder Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/finder.md Illustrates how to specify whether to search for only files, only directories, or both using static and instance methods of Nette\Utils\Finder. ```php // Static methods Finder::findFiles('*.php'); // only files Finder::findDirectories('src'); // only directories Finder::find(); // everything // Instance methods for combining Finder::findDirectories('vendor') ->files(['*.php', '*.phpt']); // directories + PHP files // Or create instance first (new Finder) ->directories() ->files('*.php'); ``` -------------------------------- ### Install Nette Plugins for Claude Code Source: https://context7.com/nette/claude-code/llms.txt Commands to add the Nette marketplace and install various Nette plugins into Claude Code. These plugins extend Claude Code's capabilities for Nette Framework development. ```bash # Add the Nette marketplace to Claude Code /plugin marketplace add nette/claude-code # Install the main Nette plugin for application developers /plugin install nette@nette # Install for Nette Framework contributors (optional) /plugin install nette-dev@nette # Install PHP code style fixer (optional) /plugin install php-fixer@nette /install-php-fixer ``` -------------------------------- ### Resize Images with Nette\Utils\Image Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/image.md Demonstrates how to resize images using the Nette\Utils\Image class, including options for maintaining aspect ratio, specifying dimensions, using percentages, and applying various resize flags like OrSmaller, OrBigger, Cover, ShrinkOnly, and Stretch. ```php use Nette\Utils\Image; $image->resize(500, 300); // max 500x300, keep aspect ratio $image->resize(500, null); // width 500px, height auto $image->resize(null, 300); // width auto, height 300px $image->resize('75%', 300); // 75% width, 300px height // Resize Flags $image->resize(500, 300, Image::OrSmaller); $image->resize(500, 300, Image::OrBigger); $image->resize(500, 300, Image::Cover); $image->resize(500, 300, Image::ShrinkOnly); $image->resize(500, 300, Image::Stretch); $image->resize(500, 300, Image::ShrinkOnly | Image::Stretch); // Flipping $image->resize(null, '-100%'); // flip vertically $image->resize('-100%', '-100%'); // rotate 180° $image->resize(-125, 500); // resize & flip horizontally // Sharpening $image->sharpen(); // after resize for better quality ``` -------------------------------- ### Specify Service Parameters in Nette DI Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-configuration/SKILL.md Demonstrates how to pass parameters to service constructors. It shows both positional and named parameter usage, recommending named parameters for clarity when mixing with autowiring. ```neon services: # Good - first parameter, clear order - App\Model\ImageService(%rootDir%/storage) # Good - named parameter when mixing with autowiring - App\Model\CustomerService(ip: %ip%) - App\Model\BlogFacade(blogPath: %blog%) ``` -------------------------------- ### Create Images with Nette\Utils\Image Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/image.md Demonstrates how to create new images using the Nette\Utils\Image class. This includes creating blank images with specified dimensions and colors, loading images from files, and creating images from raw data strings. ```php use Nette\Utils\Image; use Nette\Utils\ImageColor; // Blank image (default black background) $image = Image::fromBlank(100, 200); $image = Image::fromBlank(100, 200, ImageColor::rgb(125, 0, 0)); // From file $image = Image::fromFile('photo.jpg'); $image = Image::fromFile('photo.jpg', $type); // $type receives format // From string $image = Image::fromString($data); ``` -------------------------------- ### Nette DI: Service Configuration with NEON (NEON) Source: https://context7.com/nette/claude-code/llms.txt Illustrates Nette's Dependency Injection container configuration using the NEON format. It covers anonymous and named services, autowiring, constructor injection with named parameters, factory methods, and complex service setups with `setup` calls. ```neon # config/services.neon services: # Anonymous services (auto-wired by type) - App\Model\BlogFacade - App\Model\CustomerService - App\Presentation\Accessory\TemplateFilters # Named service (when referenced elsewhere as @pohoda) pohoda: create: Nette\Database\Connection('odbc:Driver={...}') autowired: false # Service with named parameters - App\Model\PohodaImporter(pohoda: @pohoda) - App\Model\ImageService(%rootDir%/storage) - App\Model\CustomerService(ip: %ip%) # Factory method services - App\Core\RouterFactory::createRouter - Symfony\Component\HttpClient\HttpClient::create() # Complex service with setup database: create: PDO(%dsn%, %user%, %password%) setup: - setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION) # Automatic service registration search: model: in: %appDir% classes: - *Factory - *Facade - *Service # config/common.neon parameters: pagination: itemsPerPage: 20 maxItems: 1000 database: dsn: 'mysql:host=127.0.0.1;dbname=myapp' user: root password: secret options: lazy: true charset: utf8mb4 convertBoolean: true newDateTime: true application: mapping: App\Presentation\*\**Presenter errorPresenter: 4xx: Error:Error4xx 5xx: Error:Error5xx latte: strictParsing: yes extensions: - App\Presentation\Accessory\LatteExtension ``` -------------------------------- ### Essential npm Commands for Frontend Development Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/SKILL.md Provides essential npm commands for managing frontend development workflows, including starting the development server with Hot Module Replacement (HMR), building assets for production and development, and running ESLint checks. ```bash # Start the development server with HMR npm run dev # Build assets for production npm run build # Build assets for development npm run build:dev # Run ESLint checks npm run lint ``` -------------------------------- ### Text Input Validation Examples in Nette Forms (PHP) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-forms/validation.md Provides examples of common text input validations in Nette Forms, including required fields, minimum and maximum length, and pattern matching using regular expressions. It also shows email validation and number range validation. ```php // Text validation $form->addText('username') ->setRequired('Username is required.') ->addRule($form::MinLength, 'At least %d characters', 3) ->addRule($form::MaxLength, 'Maximum %d characters', 20) ->addRule($form::Pattern, 'Only letters and numbers', '[a-zA-Z0-9]+'); // Email $form->addEmail('email') ->setRequired() ->addRule($form::Email); // Number range $form->addInteger('age') ->addRule($form::Range, 'Age must be %d-%d', [18, 120]); ``` -------------------------------- ### ArrayList Class Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/arrays.md An array-like object where indexes must be integers starting from 0. ```APIDOC # ArrayList ### Description An array-like object that strictly enforces integer keys starting from 0. It throws exceptions for invalid key access or assignments. ### Usage ```php // Create a new ArrayList $list = new Nette\Utils\ArrayList; // Add elements (keys are automatically assigned) $list[] = 'a'; $list[] = 'b'; // Result: ArrayList(0 => 'a', 1 => 'b') // Attempting to access or set invalid keys will throw an exception // echo $list[-1]; // Throws Nette\OutOfRangeException // $list['foo'] = 'x'; // Throws Nette\OutOfRangeException // Add an element to the beginning $list->prepend('first'); // Result: ArrayList(0 => 'first', 1 => 'a', 2 => 'b') // Unsetting an element renumbers subsequent keys unset($list[1]); // Result: ArrayList(0 => 'first', 1 => 'b') ``` ### Methods - **prepend(mixed $value): void** - Adds an element to the beginning of the list. - **offsetExists(mixed $offset): bool** - **offsetGet(mixed $offset): mixed** - **offsetSet(mixed $offset, mixed $value): void** - **offsetUnset(mixed $offset): void** ``` -------------------------------- ### Basic Database Configuration (NEON) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-database/SKILL.md This NEON configuration block shows how to set up a single database connection for a Nette application. It includes essential parameters like DSN, user, password, and common options such as lazy connection, character set, boolean conversion, and DateTime object handling. ```neon database: dsn: 'mysql:host=127.0.0.1;dbname=myapp' user: root password: secret options: lazy: true # Connect on first query charset: utf8mb4 # Default convertBoolean: true # TINYINT(1) to bool newDateTime: true # Return DateTimeImmutable ``` -------------------------------- ### Get Image Dimensions with Nette\Utils\Image Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/image.md Shows how to retrieve the current width and height of an image object using the Nette\Utils\Image class's `getWidth` and `getHeight` methods. ```php use Nette\Utils\Image; $width = $image->getWidth(); $height = $image->getHeight(); ``` -------------------------------- ### Merge Images with Nette\Utils\Image Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/image.md Demonstrates how to overlay one image onto another using the Nette\Utils\Image class. The `place` method allows positioning the overlay image using pixel coordinates or percentages, and can also apply opacity for effects like watermarks. ```php use Nette\Utils\Image; use Nette\Utils\ImageColor; $logo = Image::fromFile('logo.png'); $blank = Image::fromBlank(320, 240, ImageColor::rgb(52, 132, 210)); // Place at position (pixels or percentages) $blank->place($logo, '80%', '80%'); // bottom-right corner $blank->place($logo, 10, 10); // top-left at 10,10 $blank->place($logo, '50%', '50%', 25); // centered, 25% opacity (watermark) ``` -------------------------------- ### Get Zero-Indexed Position of Array Key - PHP Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/arrays.md Calculates and returns the zero-indexed position (offset) of a given key within an array. Returns null if the key is not found. ```php use Nette\Utils\Arrays; $array = ['first' => 10, 'second' => 20]; Arrays::getKeyOffset($array, 'second'); // 1 ``` -------------------------------- ### Controlling Search Scope (In vs. From) with Nette\Utils\Finder Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/finder.md Explains the difference between `in()` for non-recursive searches and `from()` for recursive searches within specified directories using Nette\Utils\Finder. ```php // in() - search only in directory (not recursive) Finder::findFiles('*.php') ->in('src'); // from() - search recursively Finder::findFiles('*.php') ->from('src'); // Current directory recursively Finder::findFiles('*.php') ->from('.'); // Multiple directories Finder::findFiles('*.php') ->in(['src', 'tests']) ->from('vendor'); // Absolute paths Finder::findFiles('*.php') ->in('/var/www/html'); ``` -------------------------------- ### ArrayList Usage (PHP) Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/arrays.md Illustrates the use of Nette\Utils\ArrayList, an array-like object where indexes must be integers starting from 0. It enforces index integrity and provides methods like prepend. ```php $list = new Nette\Utils\ArrayList; $list[] = 'a'; $list[] = 'b'; // ArrayList(0 => 'a', 1 => 'b') // Throws on invalid key access echo $list[-1]; // Nette\OutOfRangeException $list['foo'] = 'x'; // Nette\OutOfRangeException // Add to beginning $list->prepend('first'); // Remove renumbers keys unset($list[1]); // ArrayList(0 => 'first', 1 => 'b') ``` -------------------------------- ### Build HTML Elements with NetteUtilsHtml Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/SKILL.md Shows how to construct HTML elements programmatically using NetteUtilsHtml. It covers creating elements with attributes, setting text content, using a fluent interface for chaining attribute assignments, and creating elements from string definitions. ```php use Nette\Utils\Html; // Create element $el = Html::el('a', ['href' => 'https://nette.org']); $el->setText('Nette'); echo $el; // Fluent interface $el = Html::el('div') ->id('container') ->class('main active') ->data('id', 123) ->setHtml('

Content

'); // Shorthand Html::el('input', ['type' => 'text', 'name' => 'email']); Html::el('div class="box"'); ``` -------------------------------- ### Latte Block Definitions and Usage Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/latte-templates/SKILL.md Demonstrates defining reusable blocks of content using `{block}` and `{define}`. It shows how to print blocks, include them from other files, and define reusable components with parameters. ```latte {block sidebar} {/block} {include sidebar} {include sidebar from 'other.latte'} {* Reusable definitions with parameters *} {define button, $text, $type = 'primary'} {/define} {include button, 'Submit'} {include button, 'Cancel', 'secondary'} ``` -------------------------------- ### phpDoc Skipped Documentation Example: Simple Property Source: https://github.com/nette/claude-code/blob/master/plugins/nette-dev/skills/php-doc/SKILL.md Illustrates a scenario where documentation can be skipped for a property because the signature (type and name) provides all necessary information, and the purpose is obvious. ```php protected readonly string $name; ``` -------------------------------- ### Nette Assets Basic Loading in Latte Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/frontend-development/SKILL.md Demonstrates the basic usage of Nette Assets to load a complete JavaScript bundle, including all its dependencies, within a Latte template. ```latte {* Loads complete bundle with all dependencies *} {asset 'front.js'} ``` -------------------------------- ### Define Factory Method Services in Nette DI Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-configuration/SKILL.md Configures services that are created using a static factory method. This is useful for services that require specific setup logic before instantiation. ```neon services: - App\Core\RouterFactory::createRouter - Symfony\Component\HttpClient\HttpClient::create() ``` -------------------------------- ### phpDoc Property Annotation Example Source: https://github.com/nette/claude-code/blob/master/plugins/nette-dev/skills/php-doc/SKILL.md Demonstrates the single-line format for `@var` annotations in phpDoc for simple property documentation. This format is concise and suitable for properties where the type and name are self-explanatory. ```php /** @var string[] */ private array $name; ``` -------------------------------- ### Reference Configuration Parameters in Nette DI Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-configuration/SKILL.md Shows how to use configuration parameters within service definitions. Parameters are accessed using the `%parameterName%` syntax. ```neon services: - App\Model\TexyProcessor('', %wwwDir%, %tempDir%/texy) - App\Tasks\ImportTask(path: %rootDir%/../data/import) - App\Model\CustomerService(ip: %ip%) ``` -------------------------------- ### Get First/Last Key of Array Element - PHP Source: https://github.com/nette/claude-code/blob/master/plugins/nette/skills/nette-utils/arrays.md Retrieves the key of the first or last element in an array. If a predicate is provided, it returns the key of the first/last element that satisfies the predicate's condition. ```php use Nette\Utils\Arrays; Arrays::firstKey(['a' => 1, 'b' => 2]); // 'a' Arrays::lastKey(['a' => 1, 'b' => 2]); // 'b' ```