azu init
The azu init command initializes an existing directory as an Azu project. This is useful when you want to add Azu to an existing project or when you've cloned a project that doesn't have Azu configuration.
Overview
azu init [options]Basic Usage
Initialize Current Directory
# Initialize the current directory as an Azu project
azu init
# Initialize with specific database
azu init --database postgres
# Initialize with specific project type
azu init --type apiInitialize Existing Project
# Navigate to existing project
cd my_existing_project
# Initialize as Azu project
azu init
# The command will:
# - Create Azu configuration files
# - Set up directory structure
# - Generate initial files
# - Install dependenciesCommand Options
--database <db>
Database type (postgres, mysql, sqlite)
postgres
--type <type>
Project type (web, api, cli)
web
--template <name>
Use specific template
default
--skip-git
Skip Git repository initialization
false
--skip-deps
Skip dependency installation
false
--force
Overwrite existing files
false
Use Cases
1. Adding Azu to Existing Crystal Project
2. Converting Rails/Sinatra Project
3. Setting Up Cloned Project
Generated Files
Configuration Files
azu.yml - Azu configuration:
shard.yml - Updated with Azu dependencies:
Directory Structure
Core Application Files
src/my_app.cr - Main application:
src/server.cr - HTTP server:
src/initializers/database.cr - Database setup:
Examples
Initialize Web Application
Initialize API Application
Initialize CLI Application
Post-Initialization Steps
1. Install Dependencies
2. Setup Database
3. Start Development
4. Generate Your First Resource
Migration from Other Frameworks
From Rails
From Sinatra
From Express.js
Troubleshooting
Permission Issues
Existing Files Conflict
Database Connection Issues
Dependency Issues
Best Practices
1. Project Structure
2. Database Selection
3. Project Type
4. Version Control
Integration with Existing Code
Preserving Existing Files
Gradual Migration
The azu init command is perfect for adding Azu to existing projects or setting up projects that don't have Azu configuration.
Next Steps:
Project Structure - Understand the generated structure
Database Commands - Setup your database
Generate Command - Create your first components
Last updated