CMS for ExperimentsLabs.com created with CakePHP 3
It's a small website made to make a presentation of projects, files and some articles...
In any case, that's not a modular CMS, with plugins and lot of stuff (as Croogo)
First notable version with all base features working:
- User management
- Administration section
- User section to
- Manage albums (groups of files)
- Manage files (images, text, video, sounds)
- Manage notes (short texts)
- Manage posts (articles)
- Manage projects (a project can have related albums, files, notes and posts)
- "Safe For Work" state for the above items
- Tagging system
- Content reporting
- Comments (private only)
- Internationalization support
- Licenses support
- A web server wich can serve PHP files
- You will need the following PHP dependencies:
- gd
- intl
- xml
- mbstring
- gd
- A database server. The following have been tested
- MySql was used during development
- Sqlite is used for tests, so it should work
- Composer
For now there is no package for Composer.
There are many ways to get started with this CMS, i'll present two of them:
I call this method the easy way as there is nothing
To get started quickly if you have a good internet connection and some coffee to relax:
For people who know how it works.
- Download this PuPHPet configuration for vagrant
- Configure it if you want.
- Create the
data/html
subfolder - Launch
vagrant up
- Delete
data/html/index.php
and download/clone this repository indata/html/
- Login on the machine and head to
/var/www/html
- Run
./setup.sh
- Configure the db access with:
'username' => 'root, 'password' => '123', 'database' => 'vagrant',
- Done. Access
https://192.168.6.200
.
- Download and install Virtualbox and Vagrant(https://www.vagrantup.com/) and check that Vagrant is in your PATH variable (accessible from everywhere in a console) by running
vagrant -v
. - Download the box configuration created with PuPHPet(https://puphpet.com/) and extract it somewhere.
- Edit the
puphet/config.yml
to fit your needs:- Change all occurrences of
my-cake3-project
by something else (elabs
is a nice choice). You'll have to change it on every new project with this vm. - If your system is a 32bit OS, change lines 6 and 7 by
puphpet/ubuntu1604-i386
- Change the
private_network
(line 26) value to something else. - Note: The vm is configured to have 768Mb memory (line 31). You can lower it to 512 if you have issues.
- Change all occurrences of
- Create a
data
folder, in wich you will create anhtml
one. This folder will be shared with the virtual machine. It's your project base. - Open a console in the vm folder and run
vagrant up
. It will download the virtual machine image and configure it. Here comes the coffee time. - When vagrant finished, remove the
data/html/index.html
file that has been created. - Clone or download this repository in
data/html
.index.php
should be directly underhtml/
. - Login on the virtual machine:
vagrant ssh
. You're in a linux machine, so now, it's linux commands. - Go to the webserver root directory:
cd /var/www/html
. - Launch the setup:
./setup.sh
and follow the instructions.- Do you want to keep the sources needed to build the css ? [Y/n]: If you select no, Sass sources will be deleted. This step downloads some JS files.
- Do you want to install the development dependencies ? [Y/n]: If you select no, composer won't download the dev. dependencies. This step runs
composer install
. - Database setup: from your OS, edit
data/html/config/app.php
and change from the line 232:'username' => 'root, 'password' => '123', 'database' => 'vagrant',
- When it's done, hit return. The tables will be created with a default admin.
- Open a browser to
https://192.168.6.200
if you haven't changed the IP address.
Notes: I had some trouble with :
phpcbf
in the vm: it changes the file mode of the fixed files.- git in the vm: Don't use it. Every file is marked as changed. Use git from your host.
- Check if your server have the good requirements.
- For the setup to work, you should have Composer installed globally.
- Download/clone this repository in a folder accessible by your webserver
- Edit
.htaccess
andwebroot/.htaccess
to add a rewriteBase option if needed. - Launch the setup:
./setup.sh
and follow the instructions.- Do you want to keep the sources needed to build the css ? [Y/n]: If you select no, Sass sources will be deleted. This step downloads some JS files.
- Do you want to install the development dependencies ? [Y/n]: If you select no, composer won't download the dev. dependencies. This step runs
composer install
. - Database setup: edit
data/html/config/app.php
and change from the line 232:'username' => 'root, 'password' => '123', 'database' => 'vagrant',
- When it's done, hit return. The tables will be created with a default admin.
- Done.
- Check if your server have the good requirements.
- Download/clone this repository in a folder accessible by your webserver
- Edit
.htaccess
andwebroot/.htaccess
to add a rewriteBase option if needed. - If you want all the SCSS dependencies to build your css:
- Follow step by step the content of
Sources/Sass/setup.sh
. And do it manually.- Strings with $XXX are variables. Check the first lines of the script, they are defined here. They are used for folder references.
- wget xxx = download xxx
- cp xxx yyy = copy xxx to yyy
- mv xxx yyy = move xxx to yyy (also used to rename the files)
- Follow step by step the content of
- Launch
composer install
to install the dependencies. Use the--no-dev
option to ignore development dependencies. - Once it's done, edit
config/app.php
for the db configuration (line 232):'username' => 'root, 'password' => '123', 'database' => 'vagrant',
- Create the tables and the default user:
bin/cake migrations migrate
bin/cake migrations seed
- Done.
I'm sorry for you, windows user, as there is no easy way for now.
As there is no composer package for elabs now, all you can do is run the update.sh
script from the virtual machine or your linux system. It will clean and re-download sass/js files and run composer update
.
Again, for Windows, sorry.
Some configuration can be made in the files in config/
folder:
- app.php : is a file with CakePHP configuration
- site_config.php : basic configuration for the CMS
You can run the PHPUnit tests if you have installed the dev dependencies: composer phpunit
.
You can run the CodeSniffer tests too: composer phpcs
.
To automatically fix some of the CodeSniffer errors you can run composer phpcbf
. But it may change the file mode too (orininally 644
on all files except the dirs: bin/
, log/
, tmp/
and vendor/bin
).
Ideas are welcome. Just open an issue to describe it.
Translations of the cms are welcome. The translation system is the same as CakePHP and located in src/Locales
.
All the files in this folder are extracted from the source files using bin/cake i18n extract
:
- Message from the core are extracted (file
cake.pot
) - Domain strings are not merged (other files)
If you want to start a new translation:
- Create a folder in
src/Locale
with the language name (i.e.: fr_FR) - Copy the
.pot
files in it. - Change the extension to
.po
. - Edit the translations with your preferred editor (Virtaal and PoEdit are my choices).
- Commit your changes with all new
.mo
files generated by the editor.
Well... Design is not really my cup of tea. For now the website is not responsive (at least not totally). If you want to do something about that, it uses Twitter Bootstrap v3.x, BootFlat, Font Awesome icons, Bootstrap Tagsinput, Codemirror and Prism.
All the CSS is generated from custom scss files located in Sources/Sass/
. The entry point is style.scss
. No other files should be generated if you want to modify the core CSS. But if you want to create other CSS files, no problem, explain it.
I usually use Koala to generate the CSS and there is a configuration file for it; all you have to do is to drag'n'drop the Sources/Sass
folder in Koala. (Notes: Sometimes, Koala will tell you the build failed, but as long as there is no error message about this, it didn't. And sometimes, Koala will not build anything on file change, so you have to manually do it.)
All the templates are located in src/Template
. For the majority of the folders, they represent a controller, except for the following (If you're familiar with CakePHP, you'll have no problem to understand):
src/Template/
│
│ [ CakePHP Prefixes: ]
│
├── Admin/ Views for the admin workspace
│ └── <Controller>/ Views for admin/<controller>/<action> views
│ └── .ctp files
├── User/ Views for the user workspace
│ └── <Controller>/ Views for user/<controller>/xxx views
│ └── .ctp files
│
│ [ Other folders: ]
│
├── Cell/ Views for cells (special elements with their own controller-like logic)
│ └── <Cell>/
│ └── .ctp files Views for the cell
├── Element/ Small chunks of templates, included in other views
│ ├── Flash/ Flash messages
│ ├── layout/ Layout elements (menus, blocks that are not controller/action specific)
│ ├── layouts/ Specific layouts (as a standard form, a standard index, ...)
│ └── ...Other dirs/ Other elements related to controllers
├── Email/ Email templates
├── Error/ Error pages templates
├── Layout/ Layouts for the public, user and admin workspaces
├── Plugin/ Views to override plugins default views
│
│ [ Other folders: ]
│
└── <Controller>/ Views for the public workspace
└── .ctp files
For basic informations about the CakePHP templates, you should look in the CakePHP Cookbook.
All notable changes to this project will be documented in CHANGELOG.md
:
- The format is based on Keep a Changelog
- This project adheres to Semantic Versioning.
You can check the issues too.
The code is licensed under the MIT license except for files that have their own licenses.
This tool was created for the pleasure to make experiments labs and use CakePHP.