Galleri is a databaseless vanilla JavaScript and vanilla PHP photo gallery. Image data is read from the filesystem and cached in JSON files, and authentication is handled through HTTP basic auth. View the demo.
- Upload and delete images from a web interface
- Group images into folders and subfolders
- Create image thumbnails automatically
- Watermark images automatically
- Resize images automatically
- Load images with infinite scroll
- View images in a lightbox
- Specify image alt tags
- Add arbitrary data to images and folders
- Apache (other servers would presumably work too, but I've only tested with Apache)
- PHP 7.4+
- Composer
Warning: This package is still a work-in-progress. Use at your own risk.
Run:
composer create-project jlbelanger/galleri-project my-gallery --repository '{"type":"vcs","url":"git@github.com:jlbelanger/galleri-project.git"}' --stability dev
The setup script will prompt you to configure various settings.
If you are using a server other than Apache (eg. nginx), delete public/.htaccess
. You will need to write your own server configuration to handle error pages, authentication, and redirects.
Ensure the following folder permissions are set:
chown -R www-data:www-data build/images
chown -R www-data:www-data build/json
PHP configuration options are defined in .env.example
. Make your changes in the .env
file created by the setup script; changes made in .env.example
will have no effect.
JS configuration options are defined in js/main.php
. Make your changes in the js/main.js
file created by the setup script.
SCSS configuration options are defined in scss/utilities/_variables.scss
. To override these settings, re-define the variables in the SCSS file in the scss
folder, then follow the instructions below to compile the SCSS changes.
If you want to make changes to the base Galleri package (rather than just changing configuration settings):
# Clone the repo
git clone https://github.com/jlbelanger/galleri.git
cd galleri
# Configure the environment settings
cp cypress.config.example.js cypress.config.js
cp cypress.env.example.json cypress.env.json
# Install dependencies
yarn install
composer install
Create a Galleri project using the regular setup. Then, in the project folder's composer.json
file, change repositories
:
"repositories": [
{
"type": "path",
"url": "../galleri",
"options": {
"symlink": true
}
}
]
In the project folder's package.json
file, change the galleri line in dependencies
:
"dependencies": {
"@jlbelanger/galleri": "link:../galleri"
}
In the project folder, run:
composer update jlbelanger/galleri
yarn install
In the galleri
folder, run:
yarn start
In another window, in the project folder, run:
yarn start
Your browser should automatically open https://localhost:3000/
In the galleri
folder, run:
./vendor/bin/phpcs
yarn lint
In the galleri
folder, run:
./vendor/bin/phpunit
yarn test:cypress
In the galleri
folder, run:
yarn build
Create an HTML file. Include the galleri.min.css
and galleri.min.js
files from the dist
folder, an empty element, and a JS call to Galleri.init()
, passing in a CSS selector for the empty element in which the gallery should be displayed.
<link rel="stylesheet" href="galleri.min.css">
<div id="galleri"></div>
<script src="galleri.min.js"></script>
<script>Galleri.init({ selector: '#galleri' });</script>
To enable authentication and allow images to be managed from the frontend, also include a <button>
with the attribute data-action="authenticate"
.
<button data-action="authenticate" type="button"></button>
Create a composer.json
file and add jlbelanger/galleri
as a dependency.
Create a PHP file that calls Jlbelanger\Galleri\Router::load()
.
<?php
require_once realpath(__DIR__ . '/../vendor/autoload.php');
// Optional: You can set the environment variables another way if you choose.
// If you don't want to use a .env file, run `composer remove vlucas/phpdotenv` and remove the two lines below.
$dotenv = Dotenv\Dotenv::createImmutable(realpath(__DIR__ . '/../'));
$dotenv->load();
Jlbelanger\Galleri\Router::load();