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.
- Creates
Want a custom packages directory? Use:
phpkg init --packages-directory=vendor
- Renames
Packages/tovendor/(or any name you pick).
Next Steps
After running init, tweak phpkg.config.json to map your code (e.g., App → src/). 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=vendorto match Composer conventions - Entry points: Set
entry-pointsin 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
- Add Command - Add packages after initializing
- Build Command - Build your project after setup
- Customization - Configure your phpkg project
- Migrate Command - Migrate from Composer
- Command Comparison - When to use which command
What's Next?
- Getting Started - Complete walkthrough of phpkg
- Concepts - Understand how phpkg works
- Best Practices - Recommended workflows and patterns