Init Command

Kickstart Your phpkg Project

Ready to manage dependencies with phpkg? The init command sets up your project in seconds, creating the foundation for autoloading functions and classes from Git repos—no Composer clutter needed.

Usage

Run this in your project's root directory:

phpkg init
  • What It Does:
    • Creates phpkg.config.json: Configures your namespace mappings and settings.
    • Creates phpkg.config-lock.json: Tracks your added packages' versions and metadata.
    • Adds a Packages/ directory: Stores source code for packages you install.

Want a custom packages directory? Use:

phpkg init --packages-directory=vendor
  • Renames Packages/ to vendor/ (or any name you pick).

Next Steps

After running init, tweak phpkg.config.json to map your code (e.g., Appsrc/). Example:

{
    "map": {"App": "src"},
    "entry-points": ["public/index.php"],
    "packages": []
}

Then, add packages with phpkg add and build with phpkg build. See Customization for details.

Examples

# 1. Initialize project
phpkg init

# 2. Configure namespaces (edit phpkg.config.json)
# 3. Add dependencies
phpkg add php-repos/observer

# 4. Build
phpkg build

# 5. Start developing
phpkg watch

Tips

  • Custom packages directory: Use --packages-directory=vendor to match Composer conventions
  • Entry points: Set entry-points in config for web apps or CLI tools
  • Namespace mapping: Map namespaces to match your directory structure
  • See also: Getting Started for a complete walkthrough

Related Commands

What's Next?

Share: