@mytechtoday/augment-extensions 0.1.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +614 -39
- package/augment-extensions/coding-standards/bash/README.md +196 -0
- package/augment-extensions/coding-standards/bash/module.json +163 -0
- package/augment-extensions/coding-standards/bash/rules/naming-conventions.md +336 -0
- package/augment-extensions/coding-standards/bash/rules/universal-standards.md +289 -0
- package/augment-extensions/coding-standards/css/README.md +40 -0
- package/augment-extensions/coding-standards/css/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/css/module.json +44 -0
- package/augment-extensions/coding-standards/css/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/css/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html/README.md +40 -0
- package/augment-extensions/coding-standards/html/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html/module.json +44 -0
- package/augment-extensions/coding-standards/html/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/README.md +194 -0
- package/augment-extensions/coding-standards/html-css-js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/html-css-js/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/html-css-js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/html-css-js/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html-css-js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/html-css-js/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html-css-js/module.json +48 -0
- package/augment-extensions/coding-standards/html-css-js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html-css-js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/html-css-js/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/html-css-js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/html-css-js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/js/README.md +46 -0
- package/augment-extensions/coding-standards/js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/js/module.json +49 -0
- package/augment-extensions/coding-standards/js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/php/README.md +248 -0
- package/augment-extensions/coding-standards/php/examples/api-endpoint-example.php +204 -0
- package/augment-extensions/coding-standards/php/examples/cli-command-example.php +206 -0
- package/augment-extensions/coding-standards/php/examples/legacy-refactoring-example.php +234 -0
- package/augment-extensions/coding-standards/php/examples/web-application-example.php +211 -0
- package/augment-extensions/coding-standards/php/examples/woocommerce-extension-example.php +215 -0
- package/augment-extensions/coding-standards/php/examples/wordpress-plugin-example.php +189 -0
- package/augment-extensions/coding-standards/php/module.json +166 -0
- package/augment-extensions/coding-standards/php/rules/api-development.md +480 -0
- package/augment-extensions/coding-standards/php/rules/category-configuration.md +332 -0
- package/augment-extensions/coding-standards/php/rules/cli-tools.md +472 -0
- package/augment-extensions/coding-standards/php/rules/cms-integration.md +561 -0
- package/augment-extensions/coding-standards/php/rules/code-quality.md +402 -0
- package/augment-extensions/coding-standards/php/rules/documentation.md +425 -0
- package/augment-extensions/coding-standards/php/rules/ecommerce.md +627 -0
- package/augment-extensions/coding-standards/php/rules/error-handling.md +336 -0
- package/augment-extensions/coding-standards/php/rules/legacy-migration.md +677 -0
- package/augment-extensions/coding-standards/php/rules/naming-conventions.md +279 -0
- package/augment-extensions/coding-standards/php/rules/performance.md +392 -0
- package/augment-extensions/coding-standards/php/rules/psr-standards.md +186 -0
- package/augment-extensions/coding-standards/php/rules/security.md +358 -0
- package/augment-extensions/coding-standards/php/rules/testing.md +403 -0
- package/augment-extensions/coding-standards/php/rules/type-declarations.md +331 -0
- package/augment-extensions/coding-standards/php/rules/web-applications.md +426 -0
- package/augment-extensions/coding-standards/powershell/README.md +154 -0
- package/augment-extensions/coding-standards/powershell/examples/admin-example.ps1 +272 -0
- package/augment-extensions/coding-standards/powershell/examples/automation-example.ps1 +173 -0
- package/augment-extensions/coding-standards/powershell/examples/cloud-example.ps1 +243 -0
- package/augment-extensions/coding-standards/powershell/examples/cross-platform-example.ps1 +297 -0
- package/augment-extensions/coding-standards/powershell/examples/dsc-example.ps1 +224 -0
- package/augment-extensions/coding-standards/powershell/examples/legacy-migration-example.ps1 +340 -0
- package/augment-extensions/coding-standards/powershell/examples/module-example.psm1 +255 -0
- package/augment-extensions/coding-standards/powershell/module.json +165 -0
- package/augment-extensions/coding-standards/powershell/rules/administrative-tools.md +439 -0
- package/augment-extensions/coding-standards/powershell/rules/automation-scripts.md +240 -0
- package/augment-extensions/coding-standards/powershell/rules/cloud-orchestration.md +384 -0
- package/augment-extensions/coding-standards/powershell/rules/configuration-schema.md +383 -0
- package/augment-extensions/coding-standards/powershell/rules/cross-platform-scripts.md +482 -0
- package/augment-extensions/coding-standards/powershell/rules/dsc-configurations.md +296 -0
- package/augment-extensions/coding-standards/powershell/rules/error-handling.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/legacy-migrations.md +466 -0
- package/augment-extensions/coding-standards/powershell/rules/modules-functions.md +244 -0
- package/augment-extensions/coding-standards/powershell/rules/naming-conventions.md +266 -0
- package/augment-extensions/coding-standards/powershell/rules/performance-optimization.md +209 -0
- package/augment-extensions/coding-standards/powershell/rules/security-practices.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/testing-guidelines.md +268 -0
- package/augment-extensions/coding-standards/powershell/rules/universal-standards.md +197 -0
- package/augment-extensions/coding-standards/python/README.md +12 -8
- package/augment-extensions/coding-standards/python/examples/best-practices.py +373 -0
- package/augment-extensions/coding-standards/python/module.json +8 -4
- package/augment-extensions/coding-standards/python/rules/async-patterns.md +884 -0
- package/augment-extensions/coding-standards/python/rules/documentation.md +831 -0
- package/augment-extensions/coding-standards/python/rules/error-handling.md +855 -68
- package/augment-extensions/coding-standards/python/rules/testing.md +409 -0
- package/augment-extensions/coding-standards/python/rules/tooling.md +446 -0
- package/augment-extensions/coding-standards/python/rules/type-hints.md +115 -50
- package/augment-extensions/collections/html-css-js/README.md +82 -0
- package/augment-extensions/collections/html-css-js/collection.json +41 -0
- package/augment-extensions/domain-rules/database/README.md +161 -0
- package/augment-extensions/domain-rules/database/examples/flat-database-example.md +793 -0
- package/augment-extensions/domain-rules/database/examples/hybrid-database-example.md +1132 -0
- package/augment-extensions/domain-rules/database/examples/nosql-document-example.md +868 -0
- package/augment-extensions/domain-rules/database/examples/nosql-graph-example.md +805 -0
- package/augment-extensions/domain-rules/database/examples/relational-schema-example.md +621 -0
- package/augment-extensions/domain-rules/database/examples/vector-database-example.md +965 -0
- package/augment-extensions/domain-rules/database/module.json +28 -0
- package/augment-extensions/domain-rules/database/rules/flat-databases.md +624 -0
- package/augment-extensions/domain-rules/database/rules/nosql-databases.md +588 -0
- package/augment-extensions/domain-rules/database/rules/nosql-document-stores.md +856 -0
- package/augment-extensions/domain-rules/database/rules/nosql-graph-databases.md +778 -0
- package/augment-extensions/domain-rules/database/rules/nosql-key-value-stores.md +963 -0
- package/augment-extensions/domain-rules/database/rules/performance-optimization.md +1076 -0
- package/augment-extensions/domain-rules/database/rules/relational-databases.md +697 -0
- package/augment-extensions/domain-rules/database/rules/relational-indexing.md +671 -0
- package/augment-extensions/domain-rules/database/rules/relational-query-optimization.md +607 -0
- package/augment-extensions/domain-rules/database/rules/relational-schema-design.md +907 -0
- package/augment-extensions/domain-rules/database/rules/relational-transactions.md +783 -0
- package/augment-extensions/domain-rules/database/rules/security-standards.md +980 -0
- package/augment-extensions/domain-rules/database/rules/universal-best-practices.md +485 -0
- package/augment-extensions/domain-rules/database/rules/vector-databases.md +521 -0
- package/augment-extensions/domain-rules/database/rules/vector-embeddings.md +858 -0
- package/augment-extensions/domain-rules/database/rules/vector-indexing.md +934 -0
- package/augment-extensions/domain-rules/mcp/README.md +150 -0
- package/augment-extensions/domain-rules/mcp/examples/compressed-example.md +522 -0
- package/augment-extensions/domain-rules/mcp/examples/graph-augmented-example.md +520 -0
- package/augment-extensions/domain-rules/mcp/examples/hybrid-example.md +570 -0
- package/augment-extensions/domain-rules/mcp/examples/state-based-example.md +427 -0
- package/augment-extensions/domain-rules/mcp/examples/token-based-example.md +435 -0
- package/augment-extensions/domain-rules/mcp/examples/vector-based-example.md +502 -0
- package/augment-extensions/domain-rules/mcp/module.json +49 -0
- package/augment-extensions/domain-rules/mcp/rules/compressed-mcp.md +595 -0
- package/augment-extensions/domain-rules/mcp/rules/configuration.md +345 -0
- package/augment-extensions/domain-rules/mcp/rules/graph-augmented-mcp.md +687 -0
- package/augment-extensions/domain-rules/mcp/rules/hybrid-mcp.md +636 -0
- package/augment-extensions/domain-rules/mcp/rules/state-based-mcp.md +484 -0
- package/augment-extensions/domain-rules/mcp/rules/testing-validation.md +360 -0
- package/augment-extensions/domain-rules/mcp/rules/token-based-mcp.md +393 -0
- package/augment-extensions/domain-rules/mcp/rules/universal-rules.md +194 -0
- package/augment-extensions/domain-rules/mcp/rules/vector-based-mcp.md +625 -0
- package/augment-extensions/domain-rules/wordpress/README.md +163 -0
- package/augment-extensions/domain-rules/wordpress/module.json +32 -0
- package/augment-extensions/domain-rules/wordpress/rules/coding-standards.md +617 -0
- package/augment-extensions/domain-rules/wordpress/rules/directory-structure.md +270 -0
- package/augment-extensions/domain-rules/wordpress/rules/file-patterns.md +423 -0
- package/augment-extensions/domain-rules/wordpress/rules/gutenberg-blocks.md +493 -0
- package/augment-extensions/domain-rules/wordpress/rules/performance.md +568 -0
- package/augment-extensions/domain-rules/wordpress/rules/plugin-development.md +510 -0
- package/augment-extensions/domain-rules/wordpress/rules/project-detection.md +251 -0
- package/augment-extensions/domain-rules/wordpress/rules/rest-api.md +501 -0
- package/augment-extensions/domain-rules/wordpress/rules/security.md +564 -0
- package/augment-extensions/domain-rules/wordpress/rules/theme-development.md +388 -0
- package/augment-extensions/domain-rules/wordpress/rules/woocommerce.md +441 -0
- package/augment-extensions/domain-rules/wordpress-plugin/README.md +139 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/ajax-plugin.md +1599 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/custom-post-type-plugin.md +1727 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block-plugin.md +428 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/gutenberg-block.md +422 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/mvc-plugin.md +1623 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/object-oriented-plugin.md +1343 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/rest-endpoint.md +734 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/settings-page-plugin.md +1350 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/simple-procedural-plugin.md +503 -0
- package/augment-extensions/domain-rules/wordpress-plugin/examples/singleton-plugin.md +971 -0
- package/augment-extensions/domain-rules/wordpress-plugin/module.json +53 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/activation-hooks.md +770 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/admin-interface.md +874 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/ajax-handlers.md +629 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/asset-management.md +559 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/context-providers.md +709 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/cron-jobs.md +736 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/database-management.md +1057 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/documentation-standards.md +463 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/frontend-functionality.md +478 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/gutenberg-blocks.md +818 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/internationalization.md +416 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/migration.md +667 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/performance-optimization.md +878 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-architecture.md +693 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/plugin-structure.md +352 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/rest-api.md +818 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/scaffolding-workflow.md +624 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/security-best-practices.md +866 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/testing-patterns.md +1165 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/testing.md +414 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/vscode-integration.md +751 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/woocommerce-integration.md +949 -0
- package/augment-extensions/domain-rules/wordpress-plugin/rules/wordpress-org-submission.md +458 -0
- package/augment-extensions/examples/gutenberg-block-plugin/README.md +101 -0
- package/augment-extensions/examples/gutenberg-block-plugin/examples/testimonial-block.md +428 -0
- package/augment-extensions/examples/gutenberg-block-plugin/module.json +40 -0
- package/augment-extensions/examples/rest-api-plugin/README.md +98 -0
- package/augment-extensions/examples/rest-api-plugin/examples/task-manager-api.md +1299 -0
- package/augment-extensions/examples/rest-api-plugin/module.json +40 -0
- package/augment-extensions/examples/woocommerce-extension/README.md +98 -0
- package/augment-extensions/examples/woocommerce-extension/examples/product-customizer.md +763 -0
- package/augment-extensions/examples/woocommerce-extension/module.json +40 -0
- package/augment-extensions/workflows/beads/module.json +4 -3
- package/augment-extensions/workflows/database/README.md +195 -0
- package/augment-extensions/workflows/database/ai-prompt-testing.md +295 -0
- package/augment-extensions/workflows/database/examples/migration-example.md +498 -0
- package/augment-extensions/workflows/database/examples/optimization-example.md +496 -0
- package/augment-extensions/workflows/database/examples/schema-design-example.md +444 -0
- package/augment-extensions/workflows/database/module.json +42 -0
- package/augment-extensions/workflows/database/rules/data-migration.md +249 -0
- package/augment-extensions/workflows/database/rules/documentation-standards.md +339 -0
- package/augment-extensions/workflows/database/rules/migration-workflow.md +352 -0
- package/augment-extensions/workflows/database/rules/optimization-workflow.md +435 -0
- package/augment-extensions/workflows/database/rules/schema-design-workflow.md +535 -0
- package/augment-extensions/workflows/database/rules/testing-patterns.md +305 -0
- package/augment-extensions/workflows/database/rules/workflow.md +458 -0
- package/augment-extensions/workflows/openspec/module.json +4 -3
- package/augment-extensions/workflows/wordpress-plugin/README.md +232 -0
- package/augment-extensions/workflows/wordpress-plugin/ai-prompts.md +839 -0
- package/augment-extensions/workflows/wordpress-plugin/bead-decomposition-patterns.md +854 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/complete-plugin-example.md +540 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/custom-post-type-example.md +1083 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/feature-addition-workflow.md +669 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/plugin-creation-workflow.md +597 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/secure-form-handler-example.md +925 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/security-audit-workflow.md +752 -0
- package/augment-extensions/workflows/wordpress-plugin/examples/wordpress-org-submission-workflow.md +773 -0
- package/augment-extensions/workflows/wordpress-plugin/module.json +49 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/best-practices.md +942 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/development-workflow.md +702 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/submission-workflow.md +728 -0
- package/augment-extensions/workflows/wordpress-plugin/rules/testing-workflow.md +775 -0
- package/augment-extensions/writing-standards/screenplay/README.md +171 -0
- package/augment-extensions/writing-standards/screenplay/examples/aaa-hollywood-scene.fountain +164 -0
- package/augment-extensions/writing-standards/screenplay/module.json +124 -0
- package/augment-extensions/writing-standards/screenplay/rules/universal-formatting.md +339 -0
- package/cli/MODULES.md +302 -0
- package/cli/dist/cli.js +142 -9
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/catalog.d.ts +13 -0
- package/cli/dist/commands/catalog.d.ts.map +1 -0
- package/cli/dist/commands/catalog.js +104 -0
- package/cli/dist/commands/catalog.js.map +1 -0
- package/cli/dist/commands/gui.d.ts +6 -0
- package/cli/dist/commands/gui.d.ts.map +1 -0
- package/cli/dist/commands/gui.js +211 -0
- package/cli/dist/commands/gui.js.map +1 -0
- package/cli/dist/commands/init.d.ts.map +1 -1
- package/cli/dist/commands/init.js +12 -0
- package/cli/dist/commands/init.js.map +1 -1
- package/cli/dist/commands/install-rules.d.ts +14 -0
- package/cli/dist/commands/install-rules.d.ts.map +1 -0
- package/cli/dist/commands/install-rules.js +127 -0
- package/cli/dist/commands/install-rules.js.map +1 -0
- package/cli/dist/commands/link.d.ts.map +1 -1
- package/cli/dist/commands/link.js +9 -11
- package/cli/dist/commands/link.js.map +1 -1
- package/cli/dist/commands/list.d.ts.map +1 -1
- package/cli/dist/commands/list.js +11 -28
- package/cli/dist/commands/list.js.map +1 -1
- package/cli/dist/commands/mcp.d.ts +48 -0
- package/cli/dist/commands/mcp.d.ts.map +1 -0
- package/cli/dist/commands/mcp.js +229 -0
- package/cli/dist/commands/mcp.js.map +1 -0
- package/cli/dist/commands/self-remove.d.ts +7 -0
- package/cli/dist/commands/self-remove.d.ts.map +1 -0
- package/cli/dist/commands/self-remove.js +179 -0
- package/cli/dist/commands/self-remove.js.map +1 -0
- package/cli/dist/commands/show.d.ts.map +1 -1
- package/cli/dist/commands/show.js +42 -71
- package/cli/dist/commands/show.js.map +1 -1
- package/cli/dist/commands/skill.d.ts +67 -0
- package/cli/dist/commands/skill.d.ts.map +1 -0
- package/cli/dist/commands/skill.js +513 -0
- package/cli/dist/commands/skill.js.map +1 -0
- package/cli/dist/commands/unlink.d.ts +6 -0
- package/cli/dist/commands/unlink.d.ts.map +1 -0
- package/cli/dist/commands/unlink.js +115 -0
- package/cli/dist/commands/unlink.js.map +1 -0
- package/cli/dist/commands/validate.d.ts +6 -0
- package/cli/dist/commands/validate.d.ts.map +1 -0
- package/cli/dist/commands/validate.js +159 -0
- package/cli/dist/commands/validate.js.map +1 -0
- package/cli/dist/utils/catalog-sync.d.ts +22 -0
- package/cli/dist/utils/catalog-sync.d.ts.map +1 -0
- package/cli/dist/utils/catalog-sync.js +157 -0
- package/cli/dist/utils/catalog-sync.js.map +1 -0
- package/cli/dist/utils/character-count.d.ts +56 -0
- package/cli/dist/utils/character-count.d.ts.map +1 -0
- package/cli/dist/utils/character-count.js +190 -0
- package/cli/dist/utils/character-count.js.map +1 -0
- package/cli/dist/utils/documentation-validator.d.ts +18 -0
- package/cli/dist/utils/documentation-validator.d.ts.map +1 -0
- package/cli/dist/utils/documentation-validator.js +233 -0
- package/cli/dist/utils/documentation-validator.js.map +1 -0
- package/cli/dist/utils/install-rules.d.ts +32 -0
- package/cli/dist/utils/install-rules.d.ts.map +1 -0
- package/cli/dist/utils/install-rules.js +375 -0
- package/cli/dist/utils/install-rules.js.map +1 -0
- package/cli/dist/utils/mcp-integration.d.ts +70 -0
- package/cli/dist/utils/mcp-integration.d.ts.map +1 -0
- package/cli/dist/utils/mcp-integration.js +292 -0
- package/cli/dist/utils/mcp-integration.js.map +1 -0
- package/cli/dist/utils/module-system.d.ts +153 -0
- package/cli/dist/utils/module-system.d.ts.map +1 -0
- package/cli/dist/utils/module-system.js +528 -0
- package/cli/dist/utils/module-system.js.map +1 -0
- package/cli/dist/utils/modules-catalog.d.ts +33 -0
- package/cli/dist/utils/modules-catalog.d.ts.map +1 -0
- package/cli/dist/utils/modules-catalog.js +163 -0
- package/cli/dist/utils/modules-catalog.js.map +1 -0
- package/cli/dist/utils/rule-install-hooks.d.ts +19 -0
- package/cli/dist/utils/rule-install-hooks.d.ts.map +1 -0
- package/cli/dist/utils/rule-install-hooks.js +224 -0
- package/cli/dist/utils/rule-install-hooks.js.map +1 -0
- package/cli/dist/utils/skill-system.d.ts +95 -0
- package/cli/dist/utils/skill-system.d.ts.map +1 -0
- package/cli/dist/utils/skill-system.js +313 -0
- package/cli/dist/utils/skill-system.js.map +1 -0
- package/modules.md +534 -70
- package/package.json +12 -3
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# Naming Conventions
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Consistent naming conventions improve code readability and maintainability. This document defines naming standards for all PHP code elements.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Variables and Functions
|
|
10
|
+
|
|
11
|
+
### Variables
|
|
12
|
+
|
|
13
|
+
**Format:** camelCase
|
|
14
|
+
|
|
15
|
+
**Rules:**
|
|
16
|
+
- Variable names MUST start with a lowercase letter
|
|
17
|
+
- Use descriptive names that convey meaning
|
|
18
|
+
- Avoid single-letter variables except in loops or closures
|
|
19
|
+
- Boolean variables SHOULD start with `is`, `has`, `can`, or `should`
|
|
20
|
+
|
|
21
|
+
**Examples:**
|
|
22
|
+
```php
|
|
23
|
+
// ✅ Good
|
|
24
|
+
$userName = 'John Doe';
|
|
25
|
+
$totalPrice = 99.99;
|
|
26
|
+
$isActive = true;
|
|
27
|
+
$hasPermission = false;
|
|
28
|
+
$canEdit = true;
|
|
29
|
+
|
|
30
|
+
// ❌ Bad
|
|
31
|
+
$un = 'John Doe';
|
|
32
|
+
$tp = 99.99;
|
|
33
|
+
$active = true; // Ambiguous for boolean
|
|
34
|
+
$x = 'value';
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Functions
|
|
38
|
+
|
|
39
|
+
**Format:** camelCase
|
|
40
|
+
|
|
41
|
+
**Rules:**
|
|
42
|
+
- Function names MUST start with a lowercase letter
|
|
43
|
+
- Use verb-noun combinations for clarity
|
|
44
|
+
- Be descriptive and specific
|
|
45
|
+
|
|
46
|
+
**Examples:**
|
|
47
|
+
```php
|
|
48
|
+
// ✅ Good
|
|
49
|
+
function getUserById(int $id): ?User
|
|
50
|
+
function calculateTotalPrice(array $items): float
|
|
51
|
+
function validateEmail(string $email): bool
|
|
52
|
+
|
|
53
|
+
// ❌ Bad
|
|
54
|
+
function get(int $id): ?User
|
|
55
|
+
function calc(array $items): float
|
|
56
|
+
function check(string $email): bool
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Classes and Interfaces
|
|
62
|
+
|
|
63
|
+
### Classes
|
|
64
|
+
|
|
65
|
+
**Format:** PascalCase
|
|
66
|
+
|
|
67
|
+
**Rules:**
|
|
68
|
+
- Class names MUST start with an uppercase letter
|
|
69
|
+
- Use singular nouns for entity classes
|
|
70
|
+
- Use descriptive names that indicate purpose
|
|
71
|
+
|
|
72
|
+
**Examples:**
|
|
73
|
+
```php
|
|
74
|
+
// ✅ Good
|
|
75
|
+
class User {}
|
|
76
|
+
class OrderProcessor {}
|
|
77
|
+
class PaymentGateway {}
|
|
78
|
+
class EmailValidator {}
|
|
79
|
+
|
|
80
|
+
// ❌ Bad
|
|
81
|
+
class user {}
|
|
82
|
+
class process_order {}
|
|
83
|
+
class payment {}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Abstract Classes
|
|
87
|
+
|
|
88
|
+
**Format:** PascalCase with "Abstract" prefix
|
|
89
|
+
|
|
90
|
+
**Rules:**
|
|
91
|
+
- Abstract classes SHOULD be prefixed with "Abstract"
|
|
92
|
+
- Clearly indicate the abstraction purpose
|
|
93
|
+
|
|
94
|
+
**Examples:**
|
|
95
|
+
```php
|
|
96
|
+
// ✅ Good
|
|
97
|
+
abstract class AbstractController {}
|
|
98
|
+
abstract class AbstractRepository {}
|
|
99
|
+
abstract class AbstractValidator {}
|
|
100
|
+
|
|
101
|
+
// ❌ Bad
|
|
102
|
+
abstract class Controller {}
|
|
103
|
+
abstract class BaseRepo {}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Interfaces
|
|
107
|
+
|
|
108
|
+
**Format:** PascalCase with "Interface" suffix
|
|
109
|
+
|
|
110
|
+
**Rules:**
|
|
111
|
+
- Interface names SHOULD be suffixed with "Interface"
|
|
112
|
+
- Use adjectives or nouns that describe capability
|
|
113
|
+
|
|
114
|
+
**Examples:**
|
|
115
|
+
```php
|
|
116
|
+
// ✅ Good
|
|
117
|
+
interface LoggerInterface {}
|
|
118
|
+
interface CacheInterface {}
|
|
119
|
+
interface PaymentGatewayInterface {}
|
|
120
|
+
interface SerializableInterface {}
|
|
121
|
+
|
|
122
|
+
// ❌ Bad
|
|
123
|
+
interface Logger {}
|
|
124
|
+
interface ICache {}
|
|
125
|
+
interface Payment {}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Traits
|
|
129
|
+
|
|
130
|
+
**Format:** PascalCase with "Trait" suffix
|
|
131
|
+
|
|
132
|
+
**Rules:**
|
|
133
|
+
- Trait names SHOULD be suffixed with "Trait"
|
|
134
|
+
- Use adjectives that describe the behavior
|
|
135
|
+
|
|
136
|
+
**Examples:**
|
|
137
|
+
```php
|
|
138
|
+
// ✅ Good
|
|
139
|
+
trait TimestampableTrait {}
|
|
140
|
+
trait SoftDeletableTrait {}
|
|
141
|
+
trait ValidatableTrait {}
|
|
142
|
+
|
|
143
|
+
// ❌ Bad
|
|
144
|
+
trait Timestamp {}
|
|
145
|
+
trait SoftDelete {}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Exceptions
|
|
149
|
+
|
|
150
|
+
**Format:** PascalCase with "Exception" suffix
|
|
151
|
+
|
|
152
|
+
**Rules:**
|
|
153
|
+
- Exception names SHOULD be suffixed with "Exception"
|
|
154
|
+
- Be specific about the error condition
|
|
155
|
+
|
|
156
|
+
**Examples:**
|
|
157
|
+
```php
|
|
158
|
+
// ✅ Good
|
|
159
|
+
class InvalidArgumentException extends Exception {}
|
|
160
|
+
class UserNotFoundException extends Exception {}
|
|
161
|
+
class PaymentFailedException extends Exception {}
|
|
162
|
+
|
|
163
|
+
// ❌ Bad
|
|
164
|
+
class InvalidArgument extends Exception {}
|
|
165
|
+
class UserError extends Exception {}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Constants
|
|
171
|
+
|
|
172
|
+
### Class Constants
|
|
173
|
+
|
|
174
|
+
**Format:** UPPER_SNAKE_CASE
|
|
175
|
+
|
|
176
|
+
**Rules:**
|
|
177
|
+
- Constants MUST be all uppercase
|
|
178
|
+
- Use underscores to separate words
|
|
179
|
+
- Be descriptive and specific
|
|
180
|
+
|
|
181
|
+
**Examples:**
|
|
182
|
+
```php
|
|
183
|
+
// ✅ Good
|
|
184
|
+
class OrderStatus
|
|
185
|
+
{
|
|
186
|
+
public const PENDING = 'pending';
|
|
187
|
+
public const PROCESSING = 'processing';
|
|
188
|
+
public const COMPLETED = 'completed';
|
|
189
|
+
public const CANCELLED = 'cancelled';
|
|
190
|
+
public const MAX_RETRY_COUNT = 3;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ❌ Bad
|
|
194
|
+
class OrderStatus
|
|
195
|
+
{
|
|
196
|
+
public const pending = 'pending';
|
|
197
|
+
public const Processing = 'processing';
|
|
198
|
+
public const maxRetryCount = 3;
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Global Constants
|
|
203
|
+
|
|
204
|
+
**Format:** UPPER_SNAKE_CASE
|
|
205
|
+
|
|
206
|
+
**Rules:**
|
|
207
|
+
- Avoid global constants when possible
|
|
208
|
+
- Use class constants or configuration instead
|
|
209
|
+
- If necessary, prefix with application/package name
|
|
210
|
+
|
|
211
|
+
**Examples:**
|
|
212
|
+
```php
|
|
213
|
+
// ✅ Acceptable (but prefer class constants)
|
|
214
|
+
define('APP_VERSION', '1.0.0');
|
|
215
|
+
define('APP_MAX_UPLOAD_SIZE', 10485760);
|
|
216
|
+
|
|
217
|
+
// ✅ Better
|
|
218
|
+
class AppConfig
|
|
219
|
+
{
|
|
220
|
+
public const VERSION = '1.0.0';
|
|
221
|
+
public const MAX_UPLOAD_SIZE = 10485760;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Properties
|
|
228
|
+
|
|
229
|
+
### Public Properties
|
|
230
|
+
|
|
231
|
+
**Format:** camelCase
|
|
232
|
+
|
|
233
|
+
**Examples:**
|
|
234
|
+
```php
|
|
235
|
+
class User
|
|
236
|
+
{
|
|
237
|
+
public string $firstName;
|
|
238
|
+
public string $lastName;
|
|
239
|
+
public ?string $email = null;
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Protected/Private Properties
|
|
244
|
+
|
|
245
|
+
**Format:** camelCase
|
|
246
|
+
|
|
247
|
+
**Examples:**
|
|
248
|
+
```php
|
|
249
|
+
class User
|
|
250
|
+
{
|
|
251
|
+
private int $id;
|
|
252
|
+
protected string $password;
|
|
253
|
+
private ?DateTime $lastLoginAt = null;
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Namespaces
|
|
260
|
+
|
|
261
|
+
**Format:** PascalCase
|
|
262
|
+
|
|
263
|
+
**Rules:**
|
|
264
|
+
- Namespace segments MUST use PascalCase
|
|
265
|
+
- Follow PSR-4 autoloading structure
|
|
266
|
+
- Match directory structure exactly
|
|
267
|
+
|
|
268
|
+
**Examples:**
|
|
269
|
+
```php
|
|
270
|
+
// ✅ Good
|
|
271
|
+
namespace App\Services\Payment;
|
|
272
|
+
namespace App\Http\Controllers\Api;
|
|
273
|
+
namespace App\Models\User;
|
|
274
|
+
|
|
275
|
+
// ❌ Bad
|
|
276
|
+
namespace app\services\payment;
|
|
277
|
+
namespace App\http\controllers\api;
|
|
278
|
+
```
|
|
279
|
+
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# Performance Optimization
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Performance optimization is crucial for scalable PHP applications. This document defines best practices for opcode caching, database optimization, and caching strategies.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Opcode Caching
|
|
10
|
+
|
|
11
|
+
### Enable OPcache
|
|
12
|
+
|
|
13
|
+
**Rules:**
|
|
14
|
+
- OPcache MUST be enabled in production
|
|
15
|
+
- Configure OPcache settings appropriately
|
|
16
|
+
- Avoid file-based caching in favor of memory caching
|
|
17
|
+
|
|
18
|
+
**Configuration (php.ini):**
|
|
19
|
+
```ini
|
|
20
|
+
; ✅ Good - Production OPcache settings
|
|
21
|
+
opcache.enable=1
|
|
22
|
+
opcache.memory_consumption=256
|
|
23
|
+
opcache.interned_strings_buffer=16
|
|
24
|
+
opcache.max_accelerated_files=10000
|
|
25
|
+
opcache.validate_timestamps=0 ; Disable in production
|
|
26
|
+
opcache.revalidate_freq=0
|
|
27
|
+
opcache.fast_shutdown=1
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Deployment:**
|
|
31
|
+
```php
|
|
32
|
+
// ✅ Good - Clear OPcache on deployment
|
|
33
|
+
opcache_reset();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Database Query Optimization
|
|
39
|
+
|
|
40
|
+
### Avoid N+1 Query Problems
|
|
41
|
+
|
|
42
|
+
**Rules:**
|
|
43
|
+
- Use eager loading for related data
|
|
44
|
+
- Avoid queries inside loops
|
|
45
|
+
- Use joins or batch loading
|
|
46
|
+
|
|
47
|
+
**Examples:**
|
|
48
|
+
```php
|
|
49
|
+
// ✅ Good - Eager loading
|
|
50
|
+
$users = User::with('posts', 'comments')->get();
|
|
51
|
+
foreach ($users as $user) {
|
|
52
|
+
echo $user->posts->count(); // No additional query
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ✅ Good - Batch loading
|
|
56
|
+
$userIds = [1, 2, 3, 4, 5];
|
|
57
|
+
$users = User::whereIn('id', $userIds)->get();
|
|
58
|
+
|
|
59
|
+
// ❌ Bad - N+1 problem
|
|
60
|
+
$users = User::all();
|
|
61
|
+
foreach ($users as $user) {
|
|
62
|
+
echo $user->posts()->count(); // Query for each user!
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Use Indexes
|
|
67
|
+
|
|
68
|
+
**Rules:**
|
|
69
|
+
- Add indexes to frequently queried columns
|
|
70
|
+
- Use composite indexes for multi-column queries
|
|
71
|
+
- Avoid over-indexing (impacts write performance)
|
|
72
|
+
|
|
73
|
+
**Examples:**
|
|
74
|
+
```php
|
|
75
|
+
// ✅ Good - Migration with indexes
|
|
76
|
+
Schema::create('users', function (Blueprint $table) {
|
|
77
|
+
$table->id();
|
|
78
|
+
$table->string('email')->unique(); // Index for unique constraint
|
|
79
|
+
$table->string('username')->index(); // Index for searches
|
|
80
|
+
$table->timestamp('created_at')->index(); // Index for sorting
|
|
81
|
+
$table->index(['status', 'created_at']); // Composite index
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Optimize Query Selection
|
|
86
|
+
|
|
87
|
+
**Rules:**
|
|
88
|
+
- Select only needed columns
|
|
89
|
+
- Use `exists()` instead of `count()` for existence checks
|
|
90
|
+
- Limit result sets appropriately
|
|
91
|
+
|
|
92
|
+
**Examples:**
|
|
93
|
+
```php
|
|
94
|
+
// ✅ Good - Select specific columns
|
|
95
|
+
$users = User::select('id', 'name', 'email')->get();
|
|
96
|
+
|
|
97
|
+
// ✅ Good - Check existence
|
|
98
|
+
if (User::where('email', $email)->exists()) {
|
|
99
|
+
// Email exists
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ✅ Good - Limit results
|
|
103
|
+
$recentPosts = Post::orderBy('created_at', 'desc')->limit(10)->get();
|
|
104
|
+
|
|
105
|
+
// ❌ Bad - Select all columns
|
|
106
|
+
$users = User::all(); // Loads all columns
|
|
107
|
+
|
|
108
|
+
// ❌ Bad - Count for existence
|
|
109
|
+
if (User::where('email', $email)->count() > 0) { // Slower than exists()
|
|
110
|
+
// Email exists
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Use Query Caching
|
|
115
|
+
|
|
116
|
+
**Rules:**
|
|
117
|
+
- Cache frequently accessed query results
|
|
118
|
+
- Invalidate cache when data changes
|
|
119
|
+
- Use appropriate cache TTL
|
|
120
|
+
|
|
121
|
+
**Examples:**
|
|
122
|
+
```php
|
|
123
|
+
// ✅ Good - Cache query results
|
|
124
|
+
$users = Cache::remember('active_users', 3600, function () {
|
|
125
|
+
return User::where('status', 'active')->get();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// ✅ Good - Invalidate cache on update
|
|
129
|
+
function updateUser(User $user, array $data): User
|
|
130
|
+
{
|
|
131
|
+
$user->update($data);
|
|
132
|
+
Cache::forget('active_users');
|
|
133
|
+
return $user;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Caching Strategies
|
|
140
|
+
|
|
141
|
+
### Use Memory Caching
|
|
142
|
+
|
|
143
|
+
**Rules:**
|
|
144
|
+
- Use Redis or Memcached for distributed caching
|
|
145
|
+
- Avoid file-based caching in production
|
|
146
|
+
- Implement cache warming for critical data
|
|
147
|
+
|
|
148
|
+
**Examples:**
|
|
149
|
+
```php
|
|
150
|
+
// ✅ Good - Redis caching
|
|
151
|
+
use Illuminate\Support\Facades\Redis;
|
|
152
|
+
|
|
153
|
+
function getUserPreferences(int $userId): array
|
|
154
|
+
{
|
|
155
|
+
$cacheKey = "user_prefs:{$userId}";
|
|
156
|
+
|
|
157
|
+
$cached = Redis::get($cacheKey);
|
|
158
|
+
if ($cached !== null) {
|
|
159
|
+
return json_decode($cached, true);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
$prefs = $this->loadPreferencesFromDb($userId);
|
|
163
|
+
Redis::setex($cacheKey, 3600, json_encode($prefs));
|
|
164
|
+
|
|
165
|
+
return $prefs;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ✅ Good - Cache warming
|
|
169
|
+
function warmCache(): void
|
|
170
|
+
{
|
|
171
|
+
$popularProducts = Product::orderBy('views', 'desc')->limit(100)->get();
|
|
172
|
+
|
|
173
|
+
foreach ($popularProducts as $product) {
|
|
174
|
+
Cache::put("product:{$product->id}", $product, 3600);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Cache Invalidation
|
|
180
|
+
|
|
181
|
+
**Rules:**
|
|
182
|
+
- Define clear cache invalidation strategy
|
|
183
|
+
- Use cache tags for grouped invalidation
|
|
184
|
+
- Implement versioned cache keys
|
|
185
|
+
|
|
186
|
+
**Examples:**
|
|
187
|
+
```php
|
|
188
|
+
// ✅ Good - Cache tags (Laravel)
|
|
189
|
+
Cache::tags(['users', 'active'])->put('active_users', $users, 3600);
|
|
190
|
+
Cache::tags(['users'])->flush(); // Invalidate all user caches
|
|
191
|
+
|
|
192
|
+
// ✅ Good - Versioned cache keys
|
|
193
|
+
function getCacheKey(string $key): string
|
|
194
|
+
{
|
|
195
|
+
$version = config('cache.version', 1);
|
|
196
|
+
return "{$key}:v{$version}";
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
$data = Cache::get(getCacheKey('user_stats'));
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Cache Namespacing
|
|
203
|
+
|
|
204
|
+
**Rules:**
|
|
205
|
+
- Namespace cache keys to avoid collisions
|
|
206
|
+
- Include relevant identifiers in keys
|
|
207
|
+
- Use consistent key naming conventions
|
|
208
|
+
|
|
209
|
+
**Examples:**
|
|
210
|
+
```php
|
|
211
|
+
// ✅ Good - Namespaced keys
|
|
212
|
+
$userKey = "user:{$userId}:profile";
|
|
213
|
+
$orderKey = "order:{$orderId}:items";
|
|
214
|
+
$statsKey = "stats:daily:{$date}";
|
|
215
|
+
|
|
216
|
+
// ❌ Bad - Generic keys
|
|
217
|
+
$key = "profile"; // Collision risk
|
|
218
|
+
$key = "items"; // Collision risk
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Code Optimization
|
|
224
|
+
|
|
225
|
+
### Avoid Unnecessary Computations
|
|
226
|
+
|
|
227
|
+
**Rules:**
|
|
228
|
+
- Cache computed values
|
|
229
|
+
- Avoid repeated function calls in loops
|
|
230
|
+
- Use lazy loading when appropriate
|
|
231
|
+
|
|
232
|
+
**Examples:**
|
|
233
|
+
```php
|
|
234
|
+
// ✅ Good - Cache computed value
|
|
235
|
+
$count = count($items);
|
|
236
|
+
for ($i = 0; $i < $count; $i++) {
|
|
237
|
+
// Process item
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ✅ Good - Lazy loading
|
|
241
|
+
class Report
|
|
242
|
+
{
|
|
243
|
+
private ?array $data = null;
|
|
244
|
+
|
|
245
|
+
public function getData(): array
|
|
246
|
+
{
|
|
247
|
+
if ($this->data === null) {
|
|
248
|
+
$this->data = $this->loadData();
|
|
249
|
+
}
|
|
250
|
+
return $this->data;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ❌ Bad - Repeated computation
|
|
255
|
+
for ($i = 0; $i < count($items); $i++) { // count() called each iteration
|
|
256
|
+
// Process item
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Use Efficient Data Structures
|
|
261
|
+
|
|
262
|
+
**Rules:**
|
|
263
|
+
- Use arrays for indexed access
|
|
264
|
+
- Use `isset()` instead of `array_key_exists()` when possible
|
|
265
|
+
- Use generators for large datasets
|
|
266
|
+
|
|
267
|
+
**Examples:**
|
|
268
|
+
```php
|
|
269
|
+
// ✅ Good - Generator for large dataset
|
|
270
|
+
function readLargeFile(string $path): Generator
|
|
271
|
+
{
|
|
272
|
+
$handle = fopen($path, 'r');
|
|
273
|
+
|
|
274
|
+
while (($line = fgets($handle)) !== false) {
|
|
275
|
+
yield $line;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
fclose($handle);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
foreach (readLargeFile('large.txt') as $line) {
|
|
282
|
+
// Process line without loading entire file
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// ✅ Good - isset() for existence check
|
|
286
|
+
if (isset($array[$key])) {
|
|
287
|
+
// Key exists
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ❌ Bad - Load entire file into memory
|
|
291
|
+
$lines = file('large.txt'); // Memory intensive
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Optimize String Operations
|
|
295
|
+
|
|
296
|
+
**Rules:**
|
|
297
|
+
- Use single quotes for simple strings
|
|
298
|
+
- Use string interpolation instead of concatenation
|
|
299
|
+
- Use `implode()` for joining arrays
|
|
300
|
+
|
|
301
|
+
**Examples:**
|
|
302
|
+
```php
|
|
303
|
+
// ✅ Good - Single quotes (faster)
|
|
304
|
+
$name = 'John Doe';
|
|
305
|
+
|
|
306
|
+
// ✅ Good - String interpolation
|
|
307
|
+
$message = "Hello, {$name}!";
|
|
308
|
+
|
|
309
|
+
// ✅ Good - implode() for arrays
|
|
310
|
+
$parts = ['Hello', 'World'];
|
|
311
|
+
$result = implode(' ', $parts);
|
|
312
|
+
|
|
313
|
+
// ❌ Bad - Concatenation in loop
|
|
314
|
+
$result = '';
|
|
315
|
+
foreach ($items as $item) {
|
|
316
|
+
$result .= $item . ', '; // Creates new string each iteration
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ✅ Better - Build array then implode
|
|
320
|
+
$parts = [];
|
|
321
|
+
foreach ($items as $item) {
|
|
322
|
+
$parts[] = $item;
|
|
323
|
+
}
|
|
324
|
+
$result = implode(', ', $parts);
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Asset Optimization
|
|
330
|
+
|
|
331
|
+
### Minimize HTTP Requests
|
|
332
|
+
|
|
333
|
+
**Rules:**
|
|
334
|
+
- Combine CSS and JavaScript files
|
|
335
|
+
- Use asset bundlers (Webpack, Vite)
|
|
336
|
+
- Implement HTTP/2 server push when beneficial
|
|
337
|
+
|
|
338
|
+
### Enable Compression
|
|
339
|
+
|
|
340
|
+
**Rules:**
|
|
341
|
+
- Enable gzip/brotli compression
|
|
342
|
+
- Compress responses at web server level
|
|
343
|
+
|
|
344
|
+
**Configuration (Apache .htaccess):**
|
|
345
|
+
```apache
|
|
346
|
+
# ✅ Good - Enable gzip compression
|
|
347
|
+
<IfModule mod_deflate.c>
|
|
348
|
+
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
|
|
349
|
+
</IfModule>
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Use CDN for Static Assets
|
|
353
|
+
|
|
354
|
+
**Rules:**
|
|
355
|
+
- Serve static assets from CDN
|
|
356
|
+
- Use versioned asset URLs for cache busting
|
|
357
|
+
|
|
358
|
+
**Examples:**
|
|
359
|
+
```php
|
|
360
|
+
// ✅ Good - CDN with versioning
|
|
361
|
+
function assetUrl(string $path): string
|
|
362
|
+
{
|
|
363
|
+
$version = config('app.version');
|
|
364
|
+
$cdnUrl = config('app.cdn_url');
|
|
365
|
+
return "{$cdnUrl}/{$path}?v={$version}";
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Profiling and Monitoring
|
|
372
|
+
|
|
373
|
+
### Use Profiling Tools
|
|
374
|
+
|
|
375
|
+
**Tools:**
|
|
376
|
+
- Xdebug profiler
|
|
377
|
+
- Blackfire.io
|
|
378
|
+
- New Relic
|
|
379
|
+
- Tideways
|
|
380
|
+
|
|
381
|
+
**Examples:**
|
|
382
|
+
```php
|
|
383
|
+
// ✅ Good - Manual profiling
|
|
384
|
+
$start = microtime(true);
|
|
385
|
+
|
|
386
|
+
// Code to profile
|
|
387
|
+
processData($data);
|
|
388
|
+
|
|
389
|
+
$duration = microtime(true) - $start;
|
|
390
|
+
logger()->info('Processing time', ['duration' => $duration]);
|
|
391
|
+
```
|
|
392
|
+
|