Troubleshooting Guide
Common issues and solutions when working with phpkg.
Installation Issues
phpkg command not found
Symptoms: phpkg: command not found after installation
Solutions:
-
Check PATH: Verify
~/.phpkg/binis in your PATH:echo $PATH | grep phpkg -
Reload shell: Open a new terminal or reload your shell:
source ~/.bashrc # or ~/.zshrc -
Manual PATH: Add to your shell config:
echo 'export PATH="$HOME/.phpkg/bin:$PATH"' >> ~/.bashrc source ~/.bashrc -
Windows: Ensure
%USERPROFILE%\.phpkgis in your PATH. Restart PowerShell/CMD.
Installation script fails
Symptoms: Installation script errors or hangs
Solutions:
- Check internet: Ensure you can access GitHub
- Check permissions: Script needs execute permissions (Unix)
- Try manual install: Download and run the script manually
- Check PHP version: Ensure PHP 8.1+ is installed and in PATH
Package Management Issues
Package not found / Invalid identifier
Symptoms: ❌ The given identifier is invalid.
Solutions:
-
Check format: Use correct format:
# ✅ Correct phpkg add php-repos/observer phpkg add owner/repo # ❌ Wrong phpkg add observer/repo/subfolder -
Verify repository exists: Check the GitHub repository exists and is accessible
-
Use full URL: Try with full Git URL:
phpkg add https://github.com/php-repos/observer.git
Rate limit exceeded
Symptoms: Rate limit exceeded or 403 Forbidden errors
Solutions:
-
Add GitHub token:
phpkg credential github.com <your-token> -
Use environment variable:
export GITHUB_TOKEN=your_token_here -
Generate token: Create at GitHub Settings
Package has no releases
Symptoms: 🔍 Could not detect any release for the given package.
Solutions:
-
Use development version:
phpkg add owner/repo --version=developmentThis locks to the latest commit hash at the time of adding.
-
Check repository: Verify the repository has tags/releases on GitHub
-
Create a release: If it's your package, create a release tag
Version not found
Symptoms: Version vX.Y.Z not found
Solutions:
- Check available versions: Visit the repository's releases page
- Use exact version: Make sure you're using the complete version number (e.g.,
v1.2.3) - Use latest: Omit
--versionto get the latest release - Use development:
--version=developmentlocks to the latest commit hash at the time of adding/updating
Build Issues
Build fails silently
Symptoms: Build completes but code doesn't work
Solutions:
-
Check verbose output:
phpkg -vv build -
Verify entry points: Check
phpkg.config.jsonhas correct entry points -
Check namespace mapping: Ensure
mapin config matches your code structure -
Verify packages installed: Run
phpkg installfirst
Autoloading not working
Symptoms: Class not found or Function not found errors
Solutions:
-
Check import file: Ensure entry point includes:
require 'build/phpkg.imports.php'; -
Verify namespace mapping: Check
phpkg.config.json:{ "map": { "App": "src" // App\ namespace → src/ directory } } -
Rebuild: Run
phpkg buildafter config changes -
Check file structure: Ensure files match namespace structure:
src/ Utils.php → namespace App\Utils;
Build directory not found
Symptoms: build/ directory doesn't exist
Solutions:
- Run build:
phpkg buildcreates the directory - Check permissions: Ensure write permissions in project directory
- Check config: Verify
entry-pointsare set inphpkg.config.json
Runtime Issues
Standalone run fails
Symptoms: phpkg run errors or doesn't execute
Solutions:
- Check entry points: Package must have
entry-pointsinphpkg.config.json - Use verbose mode:
phpkg -vv run packagefor details - Check PHP version: Ensure PHP 8.1+ is installed
- Try full URL: Use full Git URL instead of simplified format
Serve command doesn't start
Symptoms: phpkg serve fails to start server
Solutions:
-
Check port availability: Port 8000 might be in use, try different port:
phpkg serve package --port=8080 -
Check entry points: Package needs at least one entry point
-
Windows: Ensure PHP is in PATH and
php -Sworks -
PCNTL (Unix): On Unix systems, PCNTL extension is required
Watch command not detecting changes
Symptoms: phpkg watch doesn't rebuild on file changes
Solutions:
-
Check file watching tools: Install native tools:
- macOS:
brew install fswatch - Linux:
sudo apt-get install inotify-tools - Windows: Uses polling (slower but works)
- macOS:
-
Check paths: Ensure watched files are in mapped directories
-
Manual rebuild: Use
phpkg buildif watch isn't working
Configuration Issues
Config file not found
Symptoms: 📄 Could not read the project config.
Solutions:
- Initialize project: Run
phpkg initin project root - Check location: Ensure
phpkg.config.jsonexists in current directory - Check permissions: Verify read permissions on config file
Invalid JSON in config
Symptoms: JSON parsing errors
Solutions:
- Validate JSON: Use a JSON validator or
php -r 'json_decode(file_get_contents("phpkg.config.json"));' - Check syntax: Look for trailing commas, missing quotes
- Backup and recreate: Backup config, run
phpkg init, merge changes
Packages not installing
Symptoms: phpkg install doesn't download packages
Solutions:
- Check config: Verify
packagessection has entries - Check credentials: Private repos need GitHub token
- Check network: Ensure Git access works
- Use verbose:
phpkg -vv installfor details
Performance Issues
Slow builds
Symptoms: Builds take too long
Solutions:
-
Check excludes: Add large directories to
excludes:{ "excludes": ["node_modules", "vendor", ".git"] } -
Add exclusions: Exclude unnecessary files in
excludesconfig -
Check package count: Many packages slow builds
High memory usage
Symptoms: PHP memory errors during build
Solutions:
- Increase memory:
php -d memory_limit=512M phpkg build - Reduce packages: Remove unused packages
- Check excludes: Exclude large files/directories
Git & Authentication Issues
SSH authentication fails
Symptoms: Permission denied (publickey) errors
Solutions:
- Check SSH keys: Ensure SSH key is added to GitHub
- Test SSH:
ssh -T git@github.com - Use HTTPS: Switch to HTTPS URLs instead
- Add token: Use
phpkg credentialfor HTTPS
Private repository access fails
Symptoms: 404 Not Found for private repos
Solutions:
-
Add GitHub token:
phpkg credential github.com <token> -
Check token permissions: Token needs
reposcope -
Use HTTPS: Private repos work better with HTTPS + token
Debugging Tips
Enable verbose logging
Use verbose flags to see what's happening:
phpkg -v command # Basic verbose
phpkg -vv command # More details
phpkg -vvv command # Maximum verbosity + debug
Check logs
phpkg logs are stored in:
- Unix/macOS:
~/.phpkg/Logs/phpkg.log - Windows:
%USERPROFILE%\.phpkg\Logs\phpkg.log
Verify installation
# Check version
phpkg version
# Check PHP version
php -v
# Check Git
git --version
Test package access
# Test GitHub access
curl -H "Authorization: token YOUR_TOKEN" https://api.github.com/user
# Test Git clone
git clone https://github.com/php-repos/observer.git /tmp/test
Still Stuck?
- Check FAQ: See FAQ for common questions
- Review docs: Check relevant command documentation
- Enable verbose: Use
-vvvflag for maximum debugging - Check logs: Review log files in
~/.phpkg/Logs/ - Verify versions: Ensure PHP 8.1+, Git, and phpkg are up to date
Common Error Messages
| Error | Meaning | Solution |
|---|---|---|
❌ The given identifier is invalid. |
Package format incorrect | Use owner/repo or full URL |
🔍 Could not detect any release |
No tags in repository | Use --version=development to lock to latest commit hash |
📄 Could not read the project config. |
Missing phpkg.config.json |
Run phpkg init |
🔑 Could not read credentials. |
Authentication needed | Add GitHub token |
⚠️ The package is already added |
Duplicate package | Use update instead of add |
📦 Could not get package |
Network/auth issue | Check credentials and network |
For more help, see the FAQ or review the documentation index.
Related Documentation
- FAQ - Frequently asked questions
- Installation - Installation guide
- Getting Started - Learn the basics
- Concepts - Understand how phpkg works
- Best Practices - Recommended workflows
- Command Comparison - When to use which command