Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Concerned over my initial setup,...

First of all, this being my first post here, I just want to say hello to everyone and I'm really enjoying Phalcon, after using ZF2. The documentation is pretty much, so far spot on. There are a few things I need help with. I installed phalcon-php through the AUR for Arch Linux, that part went smooth, the online documentation was right to point me there, however the PDF version of it makes no mention of where to get it from, no biggie there, just a heads up, (I might have missed it).

The virtualhost file contents are probably fine for people running anything lower than Apache 2.4, might want to mention there are a vew slight changes to make if you're using anything above that, here's mine:

<VirtualHost local.phalcon-tutorial.com:80>
    ServerAdmin [email protected]
    ServerName local.phalcon-tutorial.com
    ServerAlias local.phalcon-tutorial.com
    DocumentRoot "/webroot/phalcon-tutorial/public"

    SetEnv APPLICATION_ENV "development"

    ErrorLog "/webroot/phalcon-tutorial/logs/local.phalcon-tutorial.com-error_log"
    CustomLog "/webroot/phalcon-tutorial/logs/local.phalcon-tutorial.com-access_log" custom

    <Directory "/webroot/phalcon-tutorial/public">
        Options Indexes FollowSymLinks MultiViews
        DirectoryIndex index.php
        AllowOverride FileInfo
        Require all granted
    </Directory>
</VirtualHost>

Directing my browser to local.phalcon-tutorial.com, displays the page just fine, minus the baseurl as it is define in the index.php file in the public folder:

//Setup a base URI so that all generated URIs include the "tutorial" folder
$di->set('url', function(){
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/tutorial/'); // except mine is, $url->setBaseUrl(''/'); Read below why please,...
        return $url;
});

This is fine, that page loads and displays fine, however when it comes to the next part of the new project tutorial, setting up and introducing the signup portion of it, the page wouldn't load. Changing the above baseUrl value to what I mention in the comments beside it, cause it then to load just fine. My project directory is set up:

phalcon-tutorial/
├── app
│   ├── controllers
│   │   ├── IndexController.php
│   │   └── SignupController.php
│   ├── models
│   └── views
│       ├── index
│       │   └── index.phtml
│       └── signup
│           └── index.phtml
├── conf
│   ├── dev.phalcon-tutorial.com.conf
│   ├── local.phalcon-tutorial.com.conf
│   └── test.phalcon-tutorial.com.conf
├── logs
│   ├── dev.phalcon-tutorial.com-access_log
│   ├── dev.phalcon-tutorial.com-error_log
│   ├── local.phalcon-tutorial.com-access_log
│   ├── local.phalcon-tutorial.com-error_log
│   ├── test.phalcon-tutorial.com-access_log
│   └── test.phalcon-tutorial.com-error_log
└── public
    ├── css
    ├── img
    ├── index.php
    └── js

12 directories, 14 files

So when I added a link back to the main page, from the signup, this is what I had to do to get to work:

<?php use Phalcon\Tag; ?>

<h2>Sign up using this form</h2>

<?php echo Tag::form("signup/register"); ?>

 <p>
    <label for="name">Name</label>
    <?php echo Tag::textField("name") ?>
 </p>

 <p>
    <label for="email">E-Mail</label>
    <?php echo Tag::textField("email") ?>
 </p>

 <p>
    <?php echo Tag::submitButton("Register") ?>
 </p>

 <p>
    <?php echo Phalcon\Tag::linkTo("", "Return home!"); // This bit here was added to test how to return back to the main page / index ?>

 </p>

</form>

I know it works, for now. My main question is does anyone here see any potential problems that this might lead to, eventually? Thanks in advance and have a super wonderful rest of the day!!!



7.6k
Accepted
answer

Your setup is fine, that's the beauty of Phalcon - you aren't limited to a specific setup. I like how you've stored your apache logs and configuration files - makes for easy access should your application need to manage them via a web interface.

As a note - I think you should learn to use the Form Builder to create your forms.

Thank you! I might use this as a template then and build upon it more for what I need. I will for sure look into the Form Builder, however initially I like to understand how and why things work so it doesn't turn into a crutch.

The only thing I was concerned over was storing the database credentials in the index.php file, since I'm going to push this up to github. But for now I just ignored the index.php file in .gitignore but also made or copied the index.php, renaming it to index.php.dist, similar to how the local.php in ZF2 is ignored since it too can initially be used to store database credentials. This way anyone can use it. I did the same for the logs/ folder, can just document that I guess in the README.md file.

The most important thing with anything new I feel is documentation and community (quality of course over quantity) and so far the documentation is superb for it being in development for what? Two years, give or take? So now I'm switching over from using ZF2 to Phalcon for my PHP application development needs!

Just now saw how to implement unit testing!!! That's so awesome!!! And building a REST API!



15.4k

@18daystudios

Can you provide any links to some interesing materials for unit testing? I mean these materials you said are awesome. I am going to implement unit testing on my project - I am kind of beginner, thanks!

edited Aug '14

Hi Conradaek, with ZF2 I used PHPUnit, excellent documentation can be found here and it's super easy to install: http://phpunit.de/manual/current/en/index.html

And Phalcon from what I can see so far has some excellent documentation as well that uses PHPUnit. I highly recommend having unit tests, look eventually into a CI a continuous integration tool such as Jenkins, and to test your front end, look into Selenium / Selenium IDE / Selenium Server.