Clamp is a Command Line Apache MySQL PHP for Mac OS X made for local development. It aims at being ultra simple to use and configure.
.clamp
folder.clamp.json
JSON file.It should only be used for local development. It is absolutely not secure for anything else.
$ brew tap jide/clamp
$ brew install clamp
You must have homebrew installed.
Since in Yosemite Apache version is 2.4, you may have to correct your .htaccess file :
Order allow,deny
Becomes :
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
</IfModule>
To serve the current folder :
$ clamp
Use Ctrl + C to exit.
By default, this will start apache, create a database named "db", start MySQL daemon and set the host as "localhost". You can customize these settings using the configuration file.
You can connect to MySQL through localhost:3306 with user "root" and a blank password. Sequel pro is a great app for managing your databases.
$ clamp apache start // Start apache.
$ clamp apache stop // Stop apache.
$ clamp mysql start // Install database, start daemon and create db.
$ clamp mysql stop // Shortcut for mysql daemon stop.
$ clamp mysql daemon start // Start mysql daemon.
$ clamp mysql daemon stop // Stop mysql daemon.
$ clamp mysql install // Install.
$ clamp mysql create-db [database] // Create a database.
$ clamp mysql export [database?] [file?] // Export database.
$ clamp mysql import [file?] [database?] // Import SQL file.
$ clamp host set [host] // Add a host.
$ clamp host unset [host] // Remove a host.
$ clamp config write // Writes the default clamp.json file in the current folder.
All configuration resides in a clamp.json file. All the parameters are built using this file and then passed to the different commands. It uses a few tricks that make it very flexible.
To copy the default configuration file in the current directory, use clamp config write
.
A simple configuration :
{
"address": "localhost",
"memory": "256M",
"database": "db",
}
You can also configure each command and their options :
{
"apache": {
"commands": {},
"options": {}
},
"host": {
"options": {}
},
"mysql": {
"commands": {},
"databases": [],
"options": {}
},
"php": {
"options": {}
}
}
See the default configuration file for a detailed view of the options.
You can insert the current working direcory :
"errorlog": "'{{$cwd}}/.clamp/logs/apache.error.log'"
You can even use a path to another option :
{
"php": {
"options": {
"memory_limit": "{{$.memory}}",
"pdo_mysql.default_socket": "{{$.mysql.options.socket}}",
"mysql.default_socket": "{{$.mysql.options.socket}}",
"mysqli.default_socket": "{{$.mysql.options.socket}}"
}
}
}
Everything is self-contained in a .clamp
folder inside your project: The database files, the logs and the socket / PID files.
.clamp
- data // The database files
- logs // Apache and MySQL logs
- tmp // PID files and sockets
Note that this is the default configuration. But since you can define these paths in the configuration file, you are free to use a completly different structure.