Originally published on php2rust.dev — part of the PHP to Rust course. View this lesson on the original site.
With your project set up and dependencies in place, you can build using Cargo. By default, Cargo builds in debug mode:
cargo build
This creates a binary in target/debug/. Debug builds compile quickly and include better error messages. Use them during development.
For an optimized build (e.g. for release):
cargo build --release
The binary goes in target/release/. It runs faster but takes longer to compile.
What's next
Next: Running your project with Cargo.
From PHP to Rust — Getting Started with Rust