Flick is a PHP application that allows you to easily manage and display photo albums using files and folders with features like on-the-fly image resizing, password protection, and clean URLs. This README will guide you through setting up the application, managing your albums, theming, and more.
- Getting Started
- Directory Structure
- Adding Albums and Photos
- Metadata and Password Protection
- Theming with Blade
- Security Features
- Using Carbon for Date Formatting
- Troubleshooting
- PHP 8.0++ (with
GD
orImagick
for image processing andEXIF
for metadata extraction) - Composer (for dependency management)
- Web Server (e.g., Apache, Nginx) or PHP's built-in server for local development
-
Clone the repository:
git clone https://github.com/chrissy-dev/flick.git flick cd flick
-
Install dependencies:
Run the following command to install the necessary PHP libraries via Composer:
composer install
-
Set up the cache directory:
Ensure that the cache directory (
cache/
) exists and is writable:mkdir cache chmod 775 cache
-
Run the application:
You can start the application using PHP's built-in server:
php -S localhost:8000 -t public
Alternatively, configure your web server to serve the
public/
directory as the document root.
Once the application is running, you can access it via your web browser at:
http://localhost:8000
Here is an overview of the application's directory structure:
flick/
├── app/
│ ├── Controllers/
│ ├── Models/
│ ├── Utilities/
├── public/
│ ├── index.php
│ ├── images/ # Cached and resized images
│ ├── themes/ # Theme assets, copied from theme folder
├── views/ # Blade templates
│ ├── index.blade.php
│ ├── album.blade.php
│ ├── password.blade.php
├── albums/ # Place your albums here
│ ├── example-album/
│ │ ├── image1.jpg
│ │ ├── image2.png
│ │ └── meta.md # Metadata file
├── cache/ # Blade cache directory
├── composer.json
├── composer.lock
└── README.md
public/
: Contains the entry point (index.php
) and serves static files, including resized images.albums/
: Place your photo albums here. Each album should be a directory containing your photos and ameta.md
file for metadata.views/
: Contains the Blade templates used for rendering the frontend of the application.cache/
: Stores cached views generated by Blade.
To add a new album, create a directory inside the albums/
folder. Inside this directory, place your high-resolution images. The application will automatically resize and cache the images as needed. Keep in mind though, the bigger the image, the more processing that's needed.
-
Create a new album:
mkdir albums/my-vacation
-
Upload photos:
Place your images inside the
albums/my-vacation/
directory:albums/my-vacation/ ├── photo1.jpg ├── photo2.png └── meta.md
-
Access the album:
Once the photos are uploaded, you can view the album by navigating to:
http://localhost:8000/album/my-vacation
Each album can have a meta.md
file that contains metadata about the album. The meta.md
file uses YAML front matter for metadata and Markdown for content.
---
title: My Vacation
date: 2023-08-16
secret: "mypassword" # Optional: Add a password to protect the album
---
This album contains photos from my vacation to Scotland.
This whole section of the meta.md file is Markdown, go wild.
title
: The display name of the album.date
: The date associated with the album (e.g., when the photos were taken).secret
: (Optional) A password that must be entered to view the album.
If you add a secret
field in the meta.md
file, the album will be password protected. Users will need to enter the correct password to access the album. The password can be stored as plain text or encoded for now. In the future I would be good to support some form of application key encryption.
The application uses the Blade templating engine for theming. You can customise the look and feel of the application by modifying the Blade templates inside the themes/<theme>
directory.
At a minimum a theme should contain the following:
index.blade.php
: The homepage that lists all the albums.album.blade.php
: Displays photos within a specific album.password.blade.php
: The password prompt for password-protected albums.
You can modify the index.blade.php
template to change the layout of the album listing:
<ul>
@foreach ($albums as $album)
<li>
<a href="/album/{{ urlencode($album['name']) }}">
{{ $album['title'] }}
</a>
@if ($album['date'])
- {{ \Carbon\Carbon::parse($album['date'])->format('F j, Y') }}
@endif
</li>
@endforeach
</ul>
The core application looks for a compiled css file within the root of the theme folder with the same name as the theme folder. For example, For the theme themes/stog
the application will look for themes/stog/stog.css
. This file is copied to public automatically.
The application uses the Carbon library to format dates in a human-readable format. Carbon is a powerful date and time manipulation library for PHP.
@if ($album['date'])
- {{ \Carbon\Carbon::parse($album['date'])->format('F j, Y') }}
@endif
You can customise the date format using any valid date format string. For more information on Carbon, refer to the official documentation.
-
Blank Page:
- Ensure that PHP error reporting is enabled and check the logs for any errors.
- Make sure that all Composer dependencies are installed.
-
Images Not Displaying:
- Verify that the
public/images/
directory is writable and that images are being cached correctly. - Check that the
GD
orImagick
extension is installed and enabled in PHP.
- Verify that the
-
Password Not Working:
- Ensure that the password in the
meta.md
file matches the one being entered.
- Ensure that the password in the