Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>PHP CS FoldNew to Visual Studio Code? Get it now.
PHP CS Fold

PHP CS Fold

php-cs-fold

|
9 installs
| (0) | Free
Efficiently fold and unfold PHP class methods with keyboard shortcuts
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PHP CS Fold

VSCode PHP License

A powerful VSCode extension for efficiently folding and unfolding PHP class methods with simple keyboard shortcuts.

English | 中文


English

📋 Overview

PHP CS Fold is a lightweight and intuitive VSCode extension designed to enhance PHP development productivity. It provides convenient keyboard shortcuts to quickly fold and unfold PHP class methods, making code navigation and organization much easier.

✨ Features

  • Batch Operations: Fold/unfold all PHP methods in the current file at once
  • Single Method Operations: Fold/unfold individual methods based on cursor position
  • Recursive Unfolding: Completely expand method contents including nested if/for/while statements
  • Smart Detection: Automatically detects PHP method boundaries and comments
  • Cross-Platform: Works on Windows, macOS, and Linux

⌨️ Keyboard Shortcuts

Shortcut macOS Action
Ctrl+R + 1 Cmd+R + 1 Fold all PHP methods in current file
Ctrl+R + 2 Cmd+R + 2 Unfold all PHP methods in current file
Ctrl+R + 3 Cmd+R + 3 Fold current PHP method (cursor position)
Ctrl+R + 4 Cmd+R + 4 Recursively unfold current PHP method

🚀 Usage

  1. Open a PHP file in VSCode
  2. Fold all methods: Press Ctrl+R + 1 to hide all method bodies for better code overview
  3. Unfold all methods: Press Ctrl+R + 2 to expand all methods
  4. Fold single method: Place cursor anywhere within a method and press Ctrl+R + 3
  5. Recursively unfold method: Place cursor in a method and press Ctrl+R + 4 to expand everything including nested blocks

📄 Supported PHP Method Formats

The extension recognizes various PHP method declarations:

// Public methods
public function methodName() { }

// Private/protected methods  
private function methodName() { }
protected function methodName() { }

// Static methods
public static function methodName() { }
private static function methodName() { }

// Methods with multiple modifiers
public static function methodName() { }

💡 Use Cases

  • Code Review: Quickly fold all methods to see class structure
  • Navigation: Focus on specific methods while hiding others
  • Debugging: Expand only the method you're working on
  • Teaching: Show/hide code sections during presentations

🛠️ Installation

  1. Open VSCode
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "PHP CS Fold"
  4. Click Install

Or install via command line:

code --install-extension php-cs-fold

📋 Requirements

  • VSCode 1.74.0 or higher
  • PHP files (.php extension)

🐛 Issues & Feedback

If you encounter any issues or have suggestions, please:

  1. Check existing issues
  2. Create a new issue with detailed description
  3. Include PHP code samples if applicable

📝 Changelog

v0.0.1

  • Initial release
  • Basic fold/unfold functionality for all methods
  • Single method fold/unfold support
  • Recursive unfolding feature

中文

📋 概述

PHP CS Fold 是一个轻量级且直观的 VSCode 扩展,专为提高 PHP 开发效率而设计。它提供便捷的键盘快捷键来快速折叠和展开 PHP 类方法,让代码导航和组织变得更加容易。

✨ 功能特点

  • 批量操作:一次性折叠/展开当前文件中的所有 PHP 方法
  • 单个方法操作:根据光标位置折叠/展开单个方法
  • 递归展开:完全展开方法内容,包括嵌套的 if/for/while 语句
  • 智能检测:自动检测 PHP 方法边界和注释
  • 跨平台:支持 Windows、macOS 和 Linux

⌨️ 快捷键

快捷键 macOS 功能
Ctrl+R + 1 Cmd+R + 1 折叠当前文件中的所有 PHP 方法
Ctrl+R + 2 Cmd+R + 2 展开当前文件中的所有 PHP 方法
Ctrl+R + 3 Cmd+R + 3 折叠当前 PHP 方法(光标位置)
Ctrl+R + 4 Cmd+R + 4 递归展开当前 PHP 方法

🚀 使用方法

  1. 在 VSCode 中打开 PHP 文件
  2. 折叠所有方法:按 Ctrl+R + 1 隐藏所有方法体,获得更好的代码概览
  3. 展开所有方法:按 Ctrl+R + 2 展开所有方法
  4. 折叠单个方法:将光标放在方法内任意位置,按 Ctrl+R + 3
  5. 递归展开方法:将光标放在方法内,按 Ctrl+R + 4 展开所有内容包括嵌套块

📄 支持的 PHP 方法格式

扩展识别各种 PHP 方法声明:

// 公共方法
public function methodName() { }

// 私有/受保护方法
private function methodName() { }
protected function methodName() { }

// 静态方法
public static function methodName() { }
private static function methodName() { }

// 多修饰符方法
public static function methodName() { }

💡 使用场景

  • 代码审查:快速折叠所有方法查看类结构
  • 代码导航:专注于特定方法同时隐藏其他方法
  • 调试:只展开正在处理的方法
  • 教学:在演示过程中显示/隐藏代码段

🛠️ 安装

  1. 打开 VSCode
  2. 转到扩展 (Ctrl+Shift+X)
  3. 搜索 "PHP CS Fold"
  4. 点击安装

或通过命令行安装:

code --install-extension php-cs-fold

📋 要求

  • VSCode 1.74.0 或更高版本
  • PHP 文件(.php 扩展名)

🐛 问题与反馈

如果您遇到任何问题或有建议,请:

  1. 查看 现有问题
  2. 创建新问题并详细描述
  3. 如适用,请包含 PHP 代码示例

📝 更新日志

v0.0.1

  • 初始发布
  • 所有方法的基本折叠/展开功能
  • 单个方法折叠/展开支持
  • 递归展开功能

📄 License

MIT License - see LICENSE file for details.

🙏 Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.


Enjoy coding with PHP CS Fold! 🚀

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft