devilbox/docs/getting-started/create-your-first-project.rst

222 lines
6.4 KiB
ReStructuredText
Raw Normal View History

.. include:: /_includes/snippets/__ANNOUNCEMENTS__.rst
2018-03-16 08:25:51 +00:00
.. _getting_started_create_your_first_project:
2018-03-10 21:29:15 +00:00
*************************
Create your first project
*************************
2018-03-11 13:57:10 +00:00
2018-04-02 11:45:53 +00:00
.. important::
2018-06-03 18:45:01 +00:00
Ensure you have read :ref:`getting_started_directory_overview` to understand what is
going on under the hood.
2018-04-02 11:45:53 +00:00
2018-03-11 13:57:10 +00:00
.. note::
2018-06-03 18:45:01 +00:00
This section not only applies for one project, it applied for as many projects as you need.
**There is no limit in the number of projects.**
2018-03-11 13:57:10 +00:00
2018-03-16 08:25:51 +00:00
**Table of Contents**
2018-03-15 08:09:42 +00:00
2018-03-16 08:25:51 +00:00
.. contents:: :local:
2018-03-11 13:57:10 +00:00
Step 1: visit Intranet vhost page
2018-03-16 08:25:51 +00:00
=================================
2018-03-11 13:57:10 +00:00
2018-07-03 13:47:58 +00:00
Before starting, have a look at the vhost page at http://localhost/vhosts.php or
http://127.0.0.1/vhosts.php
.. seealso:: :ref:`howto_find_docker_toolbox_ip_address`
2018-03-11 13:57:10 +00:00
It should look like the screenshot below and will actually already provide the information needed to create a new project.
2018-07-08 10:42:04 +00:00
.. include:: /_includes/figures/devilbox/devilbox-intranet-vhosts-empty.rst
2018-03-11 13:57:10 +00:00
Step 2: create a project directory
2018-03-16 08:25:51 +00:00
==================================
2018-03-11 13:57:10 +00:00
In your Devilbox git directory, navigate to ``./data/www`` and create a new directory.
.. note::
2018-06-03 18:45:01 +00:00
Choose the directory name wisely, as it will be part of the domain for that project.
For this example we will use ``project-1`` as our project name.
2018-03-11 13:57:10 +00:00
.. code-block:: bash
# navigate to your Devilbox git directory
host> cd path/to devilbox
# navigate to the data directory
host> cd data/www
# create a new project directory named: project-1
host> mkdir project-1
2018-03-27 07:10:07 +00:00
Visit the vhost page again and see what has changed: http://localhost/vhosts.php
2018-03-11 13:57:10 +00:00
2018-07-08 10:42:04 +00:00
.. include:: /_includes/figures/devilbox/devilbox-intranet-vhosts-missing-htdocs.rst
2018-03-11 13:57:10 +00:00
**So what has happened?**
By having created a project directory, the web server container has created a new virtual host. However it has noticed, that the actual document root directory does not yet exist and therefore it cannot serve any files yet.
2018-03-16 08:25:51 +00:00
2018-03-11 13:57:10 +00:00
Step 3: create a docroot directory
2018-03-16 08:25:51 +00:00
==================================
2018-03-11 13:57:10 +00:00
.. note::
2018-06-03 18:45:01 +00:00
As desribed in :ref:`getting_started_directory_overview_docroot` the docroot directory name must be ``htdocs`` for now.
2018-03-11 13:57:10 +00:00
Navigate to your newly created project directory and create a directory named `htdocs` inside it.
.. code-block:: bash
# navigate to your Devilbox git directory
host> cd path/to devilbox
# navigate to your above created project directory
host> cd data/www/project-1
# create the docroot directory
host> mkdir htdocs
Vist the vhost page again and see what has changed: http://localhost/vhosts.php
2018-07-08 10:42:04 +00:00
.. include:: /_includes/figures/devilbox/devilbox-intranet-vhosts-missing-dns.rst
2018-03-11 13:57:10 +00:00
**So what has happened?**
2018-07-03 13:47:58 +00:00
By having created the docroot directory, the web server is now able to serve your files. However
it has noticed, that you have no way yet, to actually visit your project url, as no DNS record for
it exists yet.
2018-03-11 13:57:10 +00:00
2018-07-03 13:47:58 +00:00
The intranet already gives you the exact string that you can simply copy into your ``/etc/hosts``
(or ``C:\Windows\System32\drivers\etc`` for Windows) file on your host operating system to solve
this issue.
2018-03-11 13:57:10 +00:00
2018-03-16 08:25:51 +00:00
2018-03-18 16:14:55 +00:00
.. _getting_started_create_your_first_project_dns_entry:
2018-03-11 13:57:10 +00:00
Step 4: create a DNS entry
2018-03-16 08:25:51 +00:00
==========================
2018-03-11 13:57:10 +00:00
.. note::
2018-06-03 18:45:01 +00:00
This step can also be automated via the bundled DNS server to automatically provide catch-all
DNS entries to your host computer, but is outside the scope of this
*getting started tutorial*.
2018-03-11 13:57:10 +00:00
2018-07-03 13:47:58 +00:00
When using native Docker, the Devilbox intranet will provide you the exact string you need to paste
into your ``/etc/hosts`` (or ``C:\Windows\System32\drivers\etc`` for Windows).
2018-03-11 13:57:10 +00:00
.. code-block:: bash
2018-06-03 18:45:01 +00:00
# Open your /etc/hosts file with sudo or root privileges
# and add the following DNS entry
host> sudo vi /etc/hosts
2018-03-11 13:57:10 +00:00
2018-06-03 18:45:01 +00:00
127.0.0.1 project-1.loc
2018-03-11 13:57:10 +00:00
2018-07-03 13:47:58 +00:00
.. seealso::
2018-03-11 13:57:10 +00:00
2018-07-08 10:23:57 +00:00
* :ref:`howto_add_project_hosts_entry_on_mac`
* :ref:`howto_add_project_hosts_entry_on_win`
2018-03-11 13:57:10 +00:00
Vist the vhost page again and see what has changed: http://localhost/vhosts.php
2018-07-08 10:42:04 +00:00
.. include:: /_includes/figures/devilbox/devilbox-intranet-vhosts-working.rst
2018-03-11 13:57:10 +00:00
**So what has happened?**
By having created the DNS record, the Devilbox intranet is aware that everything is setup now and
gives you a link to your new project.
2018-03-16 08:25:51 +00:00
2018-07-03 13:47:58 +00:00
Step 5: visit your project
2018-03-16 08:25:51 +00:00
==========================
2018-03-11 13:57:10 +00:00
On the intranet, click on your project link. This will open your project in a new Browser tab or
visit http://project-1.loc
2018-07-08 10:42:04 +00:00
.. include:: /_includes/figures/devilbox/devilbox-project-missing-index.rst
2018-03-11 13:57:10 +00:00
**So what has happened?**
Everything is setup now, however the webserver is trying to find a ``index.php`` file in your document root which does not yet exist.
So all is left for you to do is to add your HTML or PHP files.
2018-03-16 08:25:51 +00:00
2018-07-03 13:47:58 +00:00
Step 6: create a hello world file
=================================
2018-03-11 13:57:10 +00:00
Navigate to your docroot directory within your project and create a ``index.php`` file with some output.
.. code-block:: bash
# navigate to your Devilbox git directory
host> cd path/to devilbox
# navigate to your projects docroot directory
host> cd data/www/project-1/htdocs
# Create a hello world index.php file
host> echo "<?php echo 'hello world';" > index.php
Alternatively create an ``index.php`` file in ``data/www/project-1/htdocs`` with the following contents:
.. code-block:: php
<?php echo 'hello world';
2018-03-27 07:10:07 +00:00
Visit your project url again and see what has changed: http://project-1.loc
2018-03-11 13:57:10 +00:00
2018-07-08 10:42:04 +00:00
.. include:: /_includes/figures/devilbox/devilbox-project-hello-world.rst
2018-03-11 13:57:10 +00:00
Checklist
=========
2018-03-16 08:25:51 +00:00
1. Project directory is created
2. Docroot directory is created
3. DNS entry is added to the host operating system
4. PHP files are added to your docroot directory
2018-07-03 13:47:58 +00:00
2018-07-06 07:30:52 +00:00
.. seealso:: :ref:`troubleshooting`
2018-07-03 13:47:58 +00:00
Further examples
================
If you already want to know how to setup specific frameworks on the Devilbox, jump directly to
their articles:
.. seealso::
**Well tested frameworks on the Devilbox**
* :ref:`example_setup_cakephp`
* :ref:`example_setup_codeigniter`
* :ref:`example_setup_craftcms`
2018-07-03 13:47:58 +00:00
* :ref:`example_setup_drupal`
2020-03-19 15:27:04 +00:00
* :ref:`example_setup_expressionengine`
2018-07-03 13:47:58 +00:00
* :ref:`example_setup_joomla`
* :ref:`example_setup_laravel`
2018-07-31 22:10:19 +00:00
* :ref:`example_setup_magento`
2018-07-03 13:47:58 +00:00
* :ref:`example_setup_phalcon`
* :ref:`example_setup_photon_cms`
2018-07-31 18:21:56 +00:00
* :ref:`example_setup_presta_shop`
2018-07-10 18:59:52 +00:00
* :ref:`example_setup_shopware`
2018-07-03 13:47:58 +00:00
* :ref:`example_setup_symfony`
2018-07-03 14:27:00 +00:00
* :ref:`example_setup_typo3`
2018-07-03 13:47:58 +00:00
* :ref:`example_setup_wordpress`
* :ref:`example_setup_yii`
* :ref:`example_setup_zend`
.. seealso::
**Generic information for all unlisted frameworks**
* :ref:`example_setup_other_frameworks`