Overview of Web Application Procurement on Zend Framework 3

    This article is a review and does not contain any how-to-tutorials. If you accidentally "run into" it on the network, then I warn you right away that it will not teach you how to use Zend Framework 3 (hereinafter ZF3).

    Cover


    Hello reader! I decided to announce my brainchild on the wonderful resource Habrahabr. I am not a regular reader, but I understand that the bulk of people looking for something interesting stumbles across here. A specialist came here for traffic, because there is no strength to watch more the death of his creations.


    Introduction


    Having once again looked at my GitHub profile, I realized that all my work was wasted. They disappear due to the fact that no one knows about these repositories. Because of this, very good, in my opinion, repositories are "dying". I try to support some, but most of them are still slowly and painfully drowning in the depths of complete ignorance. The same thing happens with zf-app-blank . Although some people know about this project, I don’t know if it is being used. Now many simply simply do not see any reason to write something using ZF3. And I decided to change this, because it is a very good framework and it undeservedly remains in the shade or is used exclusively by geeks.


    The idea of ​​creating zf-app-blank was served by a love of the framework and envy of other frameworks that have some ready-made solutions in order to “start development yesterday.” Zend Framework 3 doesn’t. There is a ZendSkeletonApplication that you need to sweat a lot to produce something worthwhile, because ZF itself positions itself as a “do it yourself”, i.e. Each developer is free to do as he needs. And that's great, really. That's what I like about him.


    What's inside


    I stuffed only the most necessary packages inside, in my opinion, in order to get started. Here, not all are planned, but most of them. And he also made friends with each other.


    At the time of this writing, zf-app-blank is version 1.6.2 and has the following on board:



    About how all this interacts, I will try to someday set out in the documentation (which is not).


    Unfortunately...


    zf-app-blank does not fully solve the problem with frontend, because:


    1. the workpiece is aimed at PHP;
    2. only the problem with ZF3 is solved;
    3. in the world of frontend, everything is developing very fast;
    4. there is no time and desire to support it;
    5. for 19 stars on the project, this is pointless.

    With a decent community around the workpiece, you can think of something other than PHP, but so far everything is completely wrong.


    zf-app-blank has no documentation, so it’s completely not clear to the user how to use it. At the moment, it will be able to use it only in case of urgent need and savvy developers with experience using the Zend Framework. And it’s sad, because there’s nothing complicated here, but you won’t say anything without documentation.


    The current Vagrant-prepared environment only works on unix-like systems. If you are the owner of Windows - quickly you will not deploy the project, as it seems to me. You can deploy using your environment and get through all the tests for environmental requirements by starting php bin/requirementsfrom the project.


    Requirements


    There are a lot of subtle points in the workpiece, for example, jQuery is used only for the debug panel. Otherwise, this is good old Javascript without anything overhead. For the JS part of Twitter, Bootstrap uses Bootstrap Native . It would be nice to have a debug panel without jQuery at all, because in 2018, having jQuery is unjustified and causing problems.


    I try to support the project and not leave it unattended. In addition to what has been implemented and uploaded, I still have many things that I have not published. For example: classes for working with Intl, improved i18n, useful Twig extentions, working environment for Docker, etc. Unfortunately, I can’t throw all my strength into this project and bring it to mind.


    Installation


    Installation will be performed using the configured Vagrant environment. For those with Windows - sorry, until this method has been tested and configured for this OS. I remind you that you can deploy a project using your environment and get through all the tests for environmental requirements by starting php bin/requirementsfrom the project.


    At the time of writing, I have Vagrant version 2.0.0. If you have lower - I recommend updating.


    To find out your version, enter the following:


    $ vagrant --version
    Vagrant 2.0.0

    The whole installation boils down to just following the instructions from the README.md repository.


    Install Vagrant Plugins:


    $ vagrant plugin install vagrant-vbguest
    $ vagrant plugin install vagrant-hostmanager

    Clone the repository:


    $ git clone https://github.com/bupy7/zf-app-blank.git

    We modify .gitignore in the project root:


    Delete the following lines:


    # delete before to create own project
    /yarn.lock
    /composer.lock

    Let's start the environment installation process:


    $ vagrant up

    After entering this command, we will be asked to slightly correct the file workenv/config/vagrant-local.yml, namely, specify the Github token. How to get a token can be found here .


    Let's indicate our token:


    github_token: 62dbd9a1ee8c89d9127aee31234b51e6

    And change the server time zone to Moscow:


    server_time_zone: Europe/Moscow

    Or you can change it to yours.


    You can also change the database to PostgreSQL if you want (MySQL is used by default):


    db_type: pgsql

    There are other interesting settings that I will talk about next time. =)


    After that, enter again:


    $ vagrant up

    and the process will resume. We are patient, we are waiting for the end and the invitation to start work (see image below):


    Far from running away, because you will need to enter the user password from which you launched Vagrant.

    Installed


    Setting up a database connection for those who chose the PostgreSQL database:


    The file /config/autoload/local.phpneeds to comment out the 8th, 15th and 19th line. Uncomment line 7, 14 and 18. Those. should be something like this:


    use Doctrine\DBAL\Driver\PDOPgSql\Driver as PgSqlDriver;
    //use Doctrine\DBAL\Driver\PDOMySql\Driver as MySqlDriver;
    return [
        'doctrine' => [
            'connection' => [
                'orm_default' => [
                    'driverClass' => PgSqlDriver::class,
    //                'driverClass' => MySqlDriver::class,
                    'params' => [
                        'host' => '127.0.0.1',
                        'port' => 5432,
    //                    'port' => 3306,
                        'user' => 'zf_app_blank',
                        'password' => '1234',
                        'dbname' => 'zf_app_blank' . (APP_ENV_TEST ? '_test' : ''),
                    ],
                ],
            ],
        ],
        ...

    Change the interface language to Russian:


    The default language is English.


    Add to the file /config/autoload/local.php:


    'translator' => [
        'locale' => 'ru',
    ],

    Change the application’s time zone to Moscow:


    Default is Europe / London.


    Add to the file /config/autoload/local.php:


    'time_zone' => [
        'time_zone' => 'Europe/Moscow',
    ],

    Create a new Postbin to receive Email messages:


    README.md is also asked to register with Mailgun and insert the key and domain into the settings, but at the development stage Postbin is enough.


    Click on the link http://bin.mailgun.net/ and copy the resulting URL to /config/autoload/local.php:


    'mailgun' => [
        'debug' => true, // оставим без изменения
        'key' => 'key-example', // оставим без изменения
        'endpoint' => 'ВСТАВИМ СЮДА НАШ URL',
    ],
    'mail' => [
        'domain' => 'example.mailgun.org', // оставим без изменения
    ],

    If you already have Mailgun and want to prescribe all the settings, then additionally disable the debug mode to receive messages to the mailbox. Postbin is then unnecessary:


    'mailgun' => [
        'debug' => false, // поменяем на false
        'key' => 'ВАШ КЛЮЧ MAILGUN',
        'endpoint' => 'http://bin.mailgun.net/not-create', // оставим без изменения
    ],
    'mail' => [
        'domain' => 'ВАШ ПОЧТОВЫЙ ДОМЕН MAILGUN',
    ],

    Finally, create the database schema:


    $ vagrant ssh -c 'php bin/console orm:schema-tool:create'

    A green message should appear:


    [OK] Database schema created successfully! 

    Meaning the success of the operation.


    Done! Now you can visit our website at: http: //zf-app-blank.local


    Signin


    Demo


    There is a small demo in this workpiece that demonstrates some basic functionality. I propose to get acquainted with it a little.


    Register a new user and confirm his Email.


    We will go to the registration page: http: //zf-app-blank.local/signup


    Enter your username, email and password.


    If you decide to use Postbin, then Email can be entered by anyone that passes validation. If not, then a real Email, where the letter could come.


    After clicking on the "Register" button, we will see a message about the successful completion of the operation.


    Image 4


    And in Postbin (or by e-mail) we will be waiting for the message that we need to confirm our Email address.


    Confirm Email


    In this letter we are interested in what is highlighted in red or a link for those who prefer sending to real Email. This is our itinerary that leads to the email confirmation page. Perform the transition: http: //zf-app-blank.local/confirm-email/example@example1.ru/29ha%5Ezzvs5b25gxwjv


    After that, they will tell us that we have successfully confirmed Email. It remains to enter the username and password.


    Homepage


    Conclusion


    It was a mini-presentation of a blank web application on ZF3. For more information visit the project repository . In the next article (if this does not go away in minus) I will tell you how to create a simple CRUD application.


    Fans of the Zend Framework and its ideology, or just those who want and are ready to help with something, will be glad of any activity in the project.


    PS Asterisks on the project are also active.


    References



    UPD


    • 01/12/2018 12:46 - More clearly stated the problem about the Vagrant-prepared environment and Windows.

    Also popular now: