Plain PHP
A plain site is a folder Cove serves over HTTPS, with PHP and nothing else. Use it for a static page, a small PHP project, or to put an https address in front of something running on a port.
Making one#
cove add notes plain # https://notes.localhost
cove add notes --plain # the sameCove makes ~/Cove/Sites/notes.localhost/public/ and puts one file in it, an index.php that says hello and shows where the folder is. Replace it with your own files. There's no database and nothing to install.
An app you already have#
--from brings in any app, from a git URL, a folder or an archive:
cove add myapp --from=https://github.com/you/myapp
cove add myapp --from=~/Projects/myapp
cove add myapp --from=https://example.com/myapp-1.2.tar.gzA repository is cloned. A folder is copied, and the original is left as it is. A .zip, .tar.gz, .tgz or .tar, a file or an https:// link, is unpacked. A Laravel project is set up as one (see Laravel), and any other app is served as it is. Nothing in it is run. plain --from= or laravel --from= says which kind it is.
Cove serves the project's public/. A project with no public/ but an index.php or index.html at the top moves into public/ whole, .git included. A cove.json at the top can say more. Cove reads it and never runs it:
{"webroot": "web", "php": "8.2", "next": "./myapp setup"}webroot is the folder to serve, php the oldest PHP the app runs on, and next a step to show when it's set up. Cove won't bring in:
- WordPress, a wp-config.php or wp-settings.php in the webroot. That comes in with cove import or cove pull.
- A download or a clone with links that point outside the project.
- A project with a file at its top named like one of Cove's own site settings, such as php_version, mappings or lan_config.
- A folder that holds ~/Cove.
The site folder is the project. cove path myapp prints its public/, the folder that's served, and the project is the folder above it.
PHP is already on#
Every .php file runs, and everything else, like HTML, CSS, images and JavaScript, is served as it is. A request for a path with no file behind it goes to index.php, so a small router works without any rewrite rules. A plain site runs on the same PHP as every other site. On macOS you can pin it to an older one. See PHP.
Errors show as a readable page with the stack trace, and go to the shared PHP error log:
cove log # the shared PHP error log
cove log notes # this site's access log
cove log -f # follow it as it growsUsing a database#
A plain site doesn't get a database, but PHP has the drivers for one: PDO for SQLite, MariaDB and PostgreSQL, mysqli, and redis.
- SQLite needs nothing else. Keep the file outside public/, in the site folder, so the web can't download it.
- MariaDB is always running. Make a database in the dashboard's SQL console or in Adminer, then connect to 127.0.0.1 as Cove's user, DB_USER and DB_PASSWORD in ~/Cove/config.
- PostgreSQL and Redis are optional: cove postgres install and cove redis install set them up.
<?php $db = new PDO( 'sqlite:' . __DIR__ . '/../notes.sqlite' );
More in Databases. Mail sent with PHP's mail() lands in Cove's mailbox, like every site's. See Mail.
HTTPS in front of a port#
Something else already running on a port, like a Node app, a Python server or a tool with a web interface? Give it a plain site and send that site's requests to the port:
cove add opencode plain
cove directive add opencode "reverse_proxy 127.0.0.1:4096"Now https://opencode.localhost answers with whatever is on port 4096, with a trusted certificate. cove directive delete opencode takes the rule away again. A directive can hold any Caddy rules, not only a proxy. See HTTPS and domains.
For a domain that isn't a Cove site, such as your computer's Tailscale name, cove proxy adds a proxy of its own:
cove proxy add opencode myhost.tailnet.ts.net 127.0.0.1:4096
cove proxy list
cove proxy delete opencodeSomething wrong or missing here? Open an issue ↗ Every command also explains itself: cove help <command>.