Tutorial updates?

Just something I'd like to request.

I followed the blog tutorial and found it confusing at many steps. At several points, it references the creation of phtml files, while the current developer tools will generate volt files. But only for some commands. Others still get phtml files, which is also confusing.

I've only ever worked with CodeIgniter and not exactly on an advanced level. The idea of Phalcon's lightning fast framework seems like a lot of fun, but I'm finding it hard to get started as the tutorials are confusing, also sometimes due to improper English.

I don't mean to be rude, it's just something that's bothering me and I think I'll try something else until it becomes more clear.



84.5k

Is this the tutorial you're mentioning?

http://blog.phalconphp.com/post/36648855158/tutorial-your-first-encounter-with-phalcon-part-2

We can help you with any questions you may have

Yes, that's the one.

I recently installed a Debian7 VM with Virtualbox, so I'll be using that. I'll follow the tutorial again and write down in my next post every issue I run in to, from top to bottom.

BTW, for people wanting to set up a really good Debian VM, I recommend this guide: https://jtreminio.com/2012/07/setting-up-a-debian-vm-step-by-step/

It details custom PHP compilation and how to setup up Samba so you can access everything from Windows. Great stuff.

Okay, first problem: installing the dev-tools with composer. I get the following error: http://i.imgur.com/CHJ6UNX.jpg

I followed the steps layed out here: http://phalconphp.com/download#devtools

On packagist.org, it does exist: https://packagist.org/packages/phalcon/devtools

But of the two options listed, only the "devmaster" branch works. The 1.0.0. @dev gives the same error as the code listed on the download page here.

EDIT: I tried cloning the devtools from github. It worked, but it's different from when composer downloaded it. Composer added a map with autoloader classes. This is very confusing, I can't make out which one I should use, which one is more up to date and why.

I need to stop at this point, because continuing with either one might lead to not being able to configure the rest of the code properly.



84.5k

I don't think there is major trouble with autoloader classes generated by composer, since your project does not depend on devtools.

As I know, composer clones the Github repository (the same as manually cloning the repository), so the same version is actually obtained using any of the two installation ways.

The devtools are being called from the commandline to auto-generate certain classes. As such, I think I prefer to simply use them without the classes added by composer, since those only serve to make them automatically load inside the project. And I won't be using them in the project. Correct me if I'm wrong, but that doesn't seem to be their intent. Their intent seems to be to using it from the commandline and to generate classes automatically.

I'll continue now.

Okay, second problem: the phalcon.sh file that generates a symlink isn't having any effect. I went in to the phalcon-devtools directory, ran the SH file as root and then tried the "phalcon" command, but it said "command not found".

I tried it again from various other directories, but it was always the same error.

I'm using the version I cloned from the github repo.



84.5k

The PATH environment variable must be pointing to the devtools installation:

echo $PATH

At least, one of the directories printed must be the devtools one. If this directory does not appear there, you can restart your console to reload the environment variables present in .profile or .bash_profile

Yes, I had to reload the console. Didn't know that one.

Anyway, I'm now running in to a permission error, which is probably my fault for not configuring the permissions properly.

This is the error, which I get right after I created the project with the devtools, in /var/www: http://i.imgur.com/1Tet9Xe.jpg I have set the hosts file propely, the URL for this is simply http://phalconblog/ , which is what I named the project.

I've checked the permissions and all the folders and files belong to my username. The .volt files however, are not set as executable.

My username is part of the www-data group, which is the group that runs the php executable.

EDIT: line 27 is simply this:

a echo $application->handle()->getContent();

(the code won't appear unless there's a letter directly after the 3 ` signs. Is that supposed to happen?)



84.5k

/var/www/phalconblog/app/cache needs write permissions for the user which is currently running the webserver daemon.

If this is a development machine you can just simply set full permissions to the whole application directory:

chmod 777 -R /var/www/phalconblog/

Even on a dev machine, I don't like using 777, since it means I won't learn how to do it properly. When the time comes to set up a production machine, I won't know how to do it.

I found a working solution here: http://superuser.com/a/19333

Now I have proper permission on all future files too.

I'll be continuing now. Was making dinner, so I was gone for a bit.

A few small things:

1) A small typo: "We will now use phalcon developer tools to take advantage of the database schema and let our tools to generate the code for us."

There should not be a "to" in "let our tools to generate the code for us.". Simply removing it is enough.

2) The tutorial then mentions: "Additionally, if you specify —relations option, like I did below, Phalcon will generate all of the model relations based on foreign keys."

But it was not done below that paragraph, it was done above it. Also, it is "specify the --relations option", not "specify --relations option".

3) An image is then shown, showing the posts/create URL. However, this functionality has not been implemented yet, and neither has the CSS. Very confusing for a tutorial to do that, showing material that has not yet been explained.

EDIT:

4) Looks like someone changed their mind on how to present the text halfway through, but forgot to delete the previous thing they typed: "Keep in mind that when using scaffolding with bootstrap option, Phalcon will only generate HTML tags with appropriate HTML classes – it is up to you you need to"

The "it is up to you" part has to be removed.

Also it's "with the bootstrap option", not "with bootstrap option".

After using the scaffold command, the tutorial says: "To check out how did that command work, simply open your browser and type: http://blog.net/posts and you should see the following result:"

But this is not true. The controller for the posts has not yet been created at this point and there are also no posts in the database yet.

Again, I'm being shown something that will only work at a later step in the tutorial. Very confusing.



84.5k

Thanks for the feedback regarding the typos and confusing paragraphs, I'm going to update the post accordingly in the next hours

I'm back. I was late last night, so I quit after the scaffolding. Will now continue.

Okay, at section 9, there is a block of code from the PostsController class.

After that, the actual code of a function is shown, but it's cut in to small pieces. This might be a preference, but I have not seen this done on any professional tutorial site before. It gives an incomplete look. Better to show the entire piece of code and then explain it, using very short paragraphs to separate the explanation.

Another reason this is bad, is that people will copy-paste this code. But most IDE's automatically insert closing brackets. This will lead to an incorrect amount of brackets, or even code being placed at a wrong scope level.

After this, a section start called "The create() action"

The lines before that say we will now see how to create a post. But the explanation is not there. The explanation that follows is for the user login. The code needed to create a post is never discussed. I had to go to the github repo for this tutorial to find it.

Step 10, views.

The file has a comment at the top, indication its location: "?<!-- app/views/index.phtml --?>"

But the developer tools created an index.volt file at this location. Also, the code displayed looks like it actually belongs in "app/views/posts/index.phtml"

Again, I had to go to the github repo to be sure I had all the correct files and code.

Also, there is a </pre> tag at the bottom, probably double.

After the routes.php file has been created and the /login route has been added, we're told to add some code to the public/index.php file.

However, the dev-tools auto-generated something different. The setting of all DI settings has been moved to app/config/services.php

Having followed the entire tutorial and having added the missing files from the repo, the whole project just does not work.

The main page remains "you are flying with phalcon" and the /login route displays an incomplete HTML table with no header.

I made a new project and simply copied all the code from the github repo. That code worked.

My only conclusion can be that the devtools have changed since the tutorial was written and that it is incompatible with the tutorial at this point.



84.5k

Thanks Koen, could you please send a pull request to the blog repo with the working version?

I'm not getting the option to do that.

The repo in question is this one: https://github.com/phalcon/blog-tutorial/

I've never done a pull request, so I don't know what to do. All I can tell you is that if I go to the pull-request tab, it simply shows an empty list that says "No pull requests to show."



84.5k

If it's easy for you, you can send me an e-mail with the code to [email protected]