Simon: The decision saved your life. Zoe: Won't happen again, sir. Mal: Good. And thanks. I'm grateful. Zoe: It was my pleasure, sir.

'Out Of Gas'


Buffistechnology 3: "Press Some Buttons, See What Happens."

Got a question about technology? Ask it here. Discussion of hardware, software, TiVos, multi-region DVDs, Windows, Macs, LINUX, hand-helds, iPods, anything tech related. Better than any helpdesk!


Gudanov - Mar 05, 2016 5:32:19 pm PST #24780 of 25496
Coding and Sleeping

Pushed some code to the PHP backend. You can see the basic structure of the REST API now even though most of it isn't implemented.

If you want to start playing with it, you'll need to take a few steps. In the noter/back directory you'll need to run:

composer install
That will download the PHP libraries you need. You'll also need to set up MySQL (or another database) with a schema and user and edit the 'propel.yml' file to those settings. Don't worry about creating tables or anything, that will be done for you.

Once 'propel.yml' is configured, then run the following commands in the noter/back directory to set up your database and generate the model classes.

vendor/bin/propel sql:build
vendor/bin/propel sql:insert
vendor/bin/propel model:build
Then you need to create the PHP configuration that the application loads in the bootstrap.php file. That is just another propel command.

vendor/bin/propel config:convert

You'll also need to make sure that Apache is configured to point to the noter/back/public directory and that the mcrypt PHP module is installed and enabled.

The Postman Chrome extension is really handy for test REST APIs. I'd recommend getting it.

I haven't run this code at all, so there are probably problems. I'll be adding more when I get a chance. Once I put in authentication, I'll make sure to run it to work out bugs and configuration issues.


Liese S. - Mar 06, 2016 7:13:54 am PST #24781 of 25496
"Faded like the lilac, he thought."

Ooh! Exciting! Thanks, Gud. It'll probably be a week before I get to start to dig into it, but I'm super amped.


Gudanov - Mar 08, 2016 6:17:24 pm PST #24782 of 25496
Coding and Sleeping

Made a couple of little corrections and ran the code so it should actually work now. Also, I added an example apache configuration file under noter/back/apache. It's an apache 2.4 config, so it will need a little tweaking for older versions. On linux anyhow, installing the config is just a matter of copying it to /etc/apache2/sites-available and then creating a link to the config in /etc/apache2/sites-enabled and then restarting apache.

I'm using api.noter.local for the server name and added it to my hosts file.

Here's a reference screen shot of an example request in Postman for registering a user.

[link]


Liese S. - Mar 09, 2016 8:02:30 am PST #24783 of 25496
"Faded like the lilac, he thought."

Cool cool. I'm home from my trip now, so I'm going to clean up the detritus that is my life as far as all the stuff that got left undone while I was gone, and then I'm going to sit down with it. Yay!


Gudanov - Mar 09, 2016 5:23:12 pm PST #24784 of 25496
Coding and Sleeping

I threw in a bunch of code real quick and probably broke all the things. It's the stuff to do authentication.


Gudanov - Mar 09, 2016 5:56:54 pm PST #24785 of 25496
Coding and Sleeping

Pfft. It wasn't all that broken. That adds support for registration and login. Logout will come later, I haven't implemented that yet for my wife's study, but all it will do is just delete the current session from the session table.

The cool thing is that the middleware layer in the Cerberus library (which I wrote real quick since I didn't like the library I found) will just take care of authenticating for the rest of the API and you don't have to worry about it. Another application-specific middleware layer will deal with updating the expiration time on the access token and the session so you don't need to deal with that either once it's in place.

One quick tip that can be confusing.

The $request and $response objects that you deal with in all the request controllers are immutable. So when you set something on them, you need to use the returned value. For example:

$response->withHeader('Content-type', 'application/json');
$value = $response->getHeader('Content-type');

Will result in $value being null.

You need to do this instead.

$response = $response->withHeader('Content-type', 'application/json');
$value = $response->getHeader('Content-type');

Which results in $value being 'application/json'

Another tip. To wipe out your database you can just run the command:

vendor/bin/propel sql:insert

from the noter/back directory. Which is handy since there is nothing that cleans out sessions yet.


Gudanov - Mar 10, 2016 3:40:19 pm PST #24786 of 25496
Coding and Sleeping

I pushed a bit more code. There's now support for basic CRUD operations through the REST api with authentication. I also added a setup.sh script to do all the stuff needed to get dependencies and generate the database support. There's also some sample data in a couple of csv files and a python script for turning that into SQL.

./csv2sql.py -u user@email.com -c categories.csv -n notes.csv > file.sql

There's a pre-generated SQL file there that will work just fine, but it expects a registered user with the email: gunnar@dog.com


DCJensen - Mar 12, 2016 1:39:22 pm PST #24787 of 25496
All is well that ends in pizza.

Anyone want a bargain smartphone with no contract?

$20 + free shipping, free minimal data talk and text.

[link]


Dana - Mar 14, 2016 4:23:03 pm PDT #24788 of 25496
I'm terrifically busy with my ennui.

My new phone is here! And it only took me four tries to enter the internet password correctly, even though I was staring right at it the whole time!


Gudanov - Mar 18, 2016 12:18:51 pm PDT #24789 of 25496
Coding and Sleeping

I've been too busy to get to the front-end, but I'm hoping to this weekend. I need to get a lot done on the front-end of my wife's study software and that's what gets adapted into my example.