What is Devflow
Devflow
is not a plug and play content management system. Devflow is a headless, event sourced PHP content management framework for rapidly developing web applications and websites. It has a simple backend with admin panel. You can build a frontend, consume the API, or build a theme. Devflow gives you a lot of flexibility to build sites for clients the way you want or need.
Installation
By following the setup step by step, you will have a working Devflow environment.
Server Requirements
- PHP >= 8.3+
- BCMath PHP Extension
- Gettext PHP Extension
- Fileinfo PHP extension
- JSON PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
- Fileinfo PHP Extension
- GD Library
- Imagick PHP Extension
Installing Devflow
Devflow utilizes Composer to manage its dependencies. So, before using Devflow, make sure you have Composer installed on your machine/server.
Composer Create-Project
You may also install Devflow by issuing the Composer create-project
command in your terminal:
composer create-project getdevflow/cmf:1.0.0-rc.2 project
After creating the project, you will need to setup your environment and edit some config. First make sure to start your database server and create a new database.
Environment Configuration
It is often helpful to have different configuration values based on the environment the application is running in. For example, you may wish to use a different cache driver locally than you do on your production server. It's easy using environment based configuration.
To make this a cinch, Devflow utilizes the DotEnv PHP library by Vance Lucas. In a fresh Devflow installation, the root directory of your application will contain a .env.example
file. You will need to manually rename this file to .evn
.
All of the variables listed in this file will be loaded into the $_ENV PHP super-global when your application receives a request. You may use the Codefy\Framework\Helpers\env
helper function to retrieve values from these variables. In fact, if you review the Devflow configuration files, you will notice several of the options already using this helper!
Feel free to modify your environment variables as needed for your own local server, as well as your production environment. However, your .env
file should not be committed to your application's source control, since each developer / server using your application could require a different environment configuration.
If you are developing with a team, you may wish to continue including a .env.example
file with your application. By putting place-holder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application.
- Open your project's root and rename
.env.example
to.env
and update the following variables:
# Application variables.
APP_NAME=
APP_ENV=dev
APP_KEY=changeme
APP_SALT=pleasechangeme
APP_ENCRYPTION_KEY=pleasechangeme
APP_DEBUG=true
APP_BASE_PATH=/opt/lampp/htdocs
APP_BASE_URL='http://localhost:8080'
# Mailer configuration
MAILER_HOST=""
MAILER_PORT=587
MAILER_USERNAME=""
MAILER_PASSWORD=""
MAILER_AUTHMODE=login
MAILER_ENCRYPTION=tls
MAILER_FROM_EMAIL="${MAILER_USERNAME}"
MAILER_FROM_NAME="${APP_NAME}"
MAILER_SENDMAIL_PATH="/usr/sbin/sendmail"
# Database setup.
DB_CONNECTION=default
DB_DRIVER=mysql
DB_HOST=localhost
DB_NAME=cms
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
DB_TABLE_PREFIX=cms_
DB_PORT=3306
DB_USER=root
DB_PASSWORD=''
To generate an APP_KEY
or APP_SALT
run the following command in the terminal: php codex generate:salt
. Replace the default values with the generated values.
To generate an APP_ENCRYPTION_KEY
run the following command in the terminal: php codex generate:key
. Replace the default values with the generated values.
Don't change the DB_TABLE_PREFIX
unless you know what you are doing.
Configs
In the root folder, open the config directory to edit auth.php
, cms.php
, and cookies.php
:
- auth.php - for security, you can change the login route, by replacing the
login
string with your custom string; also - cms.php - change the
main_site_url
andmain_site_path
to match your installation - cookies.php - change the
domain
variable and in the terminal runphp codex generate:key
for thesecret_key
- session.php - change the
domain
variable
Pretty Urls
Apache
Devflow ships with a public/.htaccess
file that is used to allow URLs without index.php
. If you use Apache to serve your application, be sure to enable the mod_rewrite
module.
If the .htaccess
file that ships with Devflow does not work with your Apache installation, try this one:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
</IfModule>
Nginx
On Nginx, the following directive in your site configuration will allow "pretty" URLs:
location / {
try_files $uri $uri/ /index.php?$args;
}
Install Command
Now that the system is configured, make sure that your database server is running
Open a terminal session, navigate to the project's root directory and run the following commands to finish installation:
# This command starts the PHP development server (https://localhost:8080).
❯ php codex serve
# This command creates the needed tables.
❯ php codex migrate
# This command installs database table information and creates the super admin user.
❯ php codex cms:install
If successful, the command will return am autogenerated username and password. Use those credentials to log into the system (default: http://localhost:8080/admin/login/)
or your custom login
route.