# CakePHP The Building Blocks

A demo project for ["CakePHP The Building Blocks"](https://docs.google.com/presentation/d/1diA6PNFxdRW_ybLdHPzzphdUWEKuybjA42QKOAfIgCY/edit?usp=sharing)

## Using authentication code from this repo in your website

Authentication is hard. This repository is here to help you.

Read [README.Authentication.md](docs/README.Authentication.md) for instructions on how to use the authentication code from this repository in your website.

## Using CMS code from this repo in your website

Websites live longer than just the time taken to build them. After the IT team hands over to a business, the administrators still need to change content without editing PHP template files.


Read [README.CMS.md](docs/README.CMS.md) for instructions on how to add a Content Management System (CMS) to your website.

## Using CAPTCHA code from this repo in your website

CAPTCHA is a very effective tool to help your website filter requests of bad intentions.


Read [README.CAPTCHA.md](docs/README.CAPTCHA.md) for instructions on how to add CloudFlare Turnstile to your website.

## Installation

1. Download [Composer](https://getcomposer.org/doc/00-intro.md) or update `composer self-update`
2. Clone the repository and go into its directory
3. Run `composer install`
4. Update `/config/app_local.php` file with correct database name and credentials
5. (Only if your database is empty) Run migrations to create tables:
```
bin/cake migrations migrate
bin/cake migrations migrate --plugin=ContentBlocks
```
6. Then seed those tables with:
```bash
# You MUST seed the content blocks as it's been used across the website!
bin/cake seeds run ContentBlocksSeed

# And you MUST seed the user table or you won't be able to login!
bin/cake seeds run UsersSeed

# However the following table seeds are optional
bin/cake seeds run BlogArticlesSeed
bin/cake seeds run ContactFormsSeed
bin/cake seeds run TestimonialsSeed
```

You can now either use your machine's webserver to view the home page, or start
up the built-in webserver with:

```bash
// To run Cake built-in development server
bin/cake server -p 8765
// To visit your website in httpd webserver
open "http://localhost:8080/cake_cms-auth/"
```

Then visit your website to see the welcome page. To login, use `test@example.com` as username, and `password` as password.

## Configuration

Read and edit the environment specific `config/app_local.php` and setup the
`'Datasources'` and any other configuration relevant for your application.
Other environment agnostic settings can be changed in `config/app.php`.

## Notes

- The project uses "Australia/Melbourne" as timezone for both the application and database. In some MySQL/MariaDB setup timezone information may not be available and will cause error. To workaround this, change timezone of both app and database to "UTC" in `/config/app.php`
