Skip to main content
Version: 4.x

Installing BowPHP

Prerequisites​

To create a new Bow application, please first make sure your computer meets the following requirements:

  • PHP >= 7.1
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • XML PHP Extension
  • JSON PHP Extension

If you are on Windows and use a web server such as Laragon, these dependencies are already satisfied.

Create a project​

BowPHP uses Composer to manage its dependencies. So, before using Bow, you first need to install Composer on your machine.

Via Composer​

composer create-project --prefer-dist bowphp/app nom-du-projet

We recommend installing composer globally on your machine. To do so, refer to Composer's installation documentation. If you are not familiar with composer, we encourage you to browse the documentation.

πŸš€ Start your project​

Go to the root of your project and start the server:

cd mon-projet
php bow run:server --port=8000 --host=0.0.0.0

Open your browser and type http://localhost:8000.

5000 is the default port when no port is specified with the php bow run:server command.

βš™οΈ Configuration​

Public Folder​

After installing BowPHP, you must configure your server's document root to point to the public folder.

The index.php file located in the public folder serves as the entry point for all HTTP requests (it is the Front Controller).

Configuration files​

All of BowPHP's configuration files are stored in the config folder. Every option is documented to help you become familiar with the available options.

Folder permissions​

After installing Bow, you will need to configure a few permissions. The folders contained in the var folder must have write permissions on the web server.

Web Server Configuration​

Apache​

Bow includes a public/.htaccess file that is used to perform URL rewriting on the front controller. Before using Bow with Apache, make sure the mod_rewrite module is enabled so that the server takes into account the instructions in the .htaccess file.

If the default .htaccess file in Bow does not work with your Apache installation, try this alternative:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Nginx​

If you use Nginx, the following directives in your configuration will redirect requests to the front controller:

location / {
try_files $uri $uri/ /index.php?$query_string;
}

Deploying on a shared server​

To deploy BowPHP on a shared server, you need to move the index.php and .htaccess files to the root of the project. Make sure the files are correctly referenced in the index.php file, then you can copy the following code into the htaccess file.

Options -indexes
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

<Files ".env.*|server.php|bow|app/**|vendor/**|postman/*|var/**|seeders/*|templates/**|tests/**|migrations/**">
Order Allow,Deny
Deny from all
</Files>

In this regard, it is recommended to reference your asset files with the app_assets method and change the value of APP_ASSET_PREFIX to /public in your .env.json, and Bow does the rest πŸ˜…

You can continue to these sections to start your development.

Is something missing?

If you run into problems with the documentation or have suggestions to improve the documentation or the project in general, please open an issue for us, or send a tweet mentioning the Twitter account @bowframework or directly on github.