ls command lists variables, constants, classes, interfaces, traits, functions, methods, and properties. Without arguments, it shows variables in the current scope. With a target, it shows members of that class or object.
Syntax
Alias
dir
Arguments
A class name or object instance to list members of
Options
What to List
Display variables in current scope (default when no target is given)
Alias:
-cDisplay defined constantsAlias:
-fDisplay defined functionsAlias:
-kDisplay declared classesAlias:
-IDisplay declared interfacesAlias:
-tDisplay declared traitsAlias:
-pDisplay class or object properties (public by default)Alias:
-mDisplay class or object methods (public by default)Filters
Filter results by pattern (supports regular expressions)
Alias:
-iMake grep search case-insensitiveAlias:
-vInvert the grep search (show non-matching items)Alias:
-gInclude global variablesAlias:
-nLimit to internal (built-in) functions and classesAlias:
-uLimit to user-defined constants, functions, and classesAlias:
-CLimit to constants in a specific category (e.g., “date”, “pcre”)Display Options
Alias:
-aInclude private and protected methods and propertiesAlias:
-lList in long format: includes class names and full signaturesExclude inherited methods, properties, and constants
Usage Examples
List Variables
By default,ls shows variables in the current scope:
- Output
List Object Members
- Output
List Class Members
Long Format
Use-l for detailed signatures:
- Output
Show Private/Protected Members
Filter with Grep
- Example
List All Classes
List Classes by Pattern
List All Functions
List User-Defined Functions
- Example
List Internal Functions
List Constants
List Constants by Category
- Example
Exclude Inherited Members
MyChildClass, not inherited from parents.
List Global Variables
$_SERVER, $_GET, $_POST, etc.
Advanced Examples
Find All Array Functions
List Private Methods
-a includes private) in method-only view (-m).
Search for Specific Properties
List All Traits
List Interfaces
Default Behavior
Without Target
Defaults to--vars:
With Target
Defaults to--constants --properties --methods:
Output Format
Short Format (Default)
Items are listed inline, separated by commas:Long Format (-l)
Items are listed one per line with full signatures:
Visibility Indicators
When using-a (all), members are color-coded:
- Public - normal color
- Protected - different color
- Private - different color