CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
      • Crypto
      • Exception
      • Fs
        • Iterator
    • Validation
    • View

Class Path

Path utility class for cross-platform path manipulation.

Provides static methods for normalizing, joining, and working with filesystem paths in a platform-independent way.

Namespace: Cake\Utility\Fs

Method Summary

  • isAbsolute() public static

    Checks if a path is absolute.

  • join() public static

    Joins path segments together using the correct directory separator.

  • makeAbsolute() public static

    Makes a path absolute, using a base path if the given path is not already absolute, and resolves any . and .. segments in the result.

  • makeRelative() public static

    Makes a path relative to a base path.

  • matches() public static

    Checks if a path matches a glob pattern.

  • normalize() public static

    Normalizes a path by converting directory separators to forward slashes and removing redundant separators.

  • resolveDotSegments() protected static

    Resolves . and .. segments in an absolute, forward-slash-normalized path.

    Segments that would go above the root (e.g. an extra .. at the root level) are simply dropped, since there is nothing above the root to resolve to.

Method Detail

isAbsolute() ¶ public static

isAbsolute(string $path): bool

Checks if a path is absolute.

Parameters
string $path

The path to check

Returns
bool

True if the path is absolute

join() ¶ public static

join(string ...$segments): string

Joins path segments together using the correct directory separator.

Parameters
string ...$segments

Path segments to join

Returns
string

The joined path

makeAbsolute() ¶ public static

makeAbsolute(string $path, string $from): string

Makes a path absolute, using a base path if the given path is not already absolute, and resolves any . and .. segments in the result.

Parameters
string $path

The path to make absolute

string $from

The base path to use when $path is relative. Expected to already be absolute.

Returns
string

The absolute, resolved path

makeRelative() ¶ public static

makeRelative(string $path, string $from): string

Makes a path relative to a base path.

Parameters
string $path

The absolute path to make relative

string $from

The base path to make relative from

Returns
string

The relative path

matches() ¶ public static

matches(string $pattern, string $path): bool

Checks if a path matches a glob pattern.

Parameters
string $pattern

The glob pattern

string $path

The path to check

Returns
bool

True if the path matches the pattern

normalize() ¶ public static

normalize(string $path, bool $trailing = false): string

Normalizes a path by converting directory separators to forward slashes and removing redundant separators.

Parameters
string $path

The path to normalize

bool $trailing optional

Whether to preserve trailing slashes

Returns
string

The normalized path

resolveDotSegments() ¶ protected static

resolveDotSegments(string $path): string

Resolves . and .. segments in an absolute, forward-slash-normalized path.

Segments that would go above the root (e.g. an extra .. at the root level) are simply dropped, since there is nothing above the root to resolve to.

Parameters
string $path

The absolute path to resolve

Returns
string

The resolved path

OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs