Modern PHP, soft skills, productivity and time management.

Category: Tech (Page 3 of 4)

PHPyths Buster: Displaying reminders

Previously I’ve made a connection to Evernote and display list of all notes. Nice. But the project is about managing reminders, so let’s go to work!

Receiving reminders

First of all, I want to display only notes with reminders. It could be done using `NoteFilter`. It’s enough to add just one line:

`$nFilter->words = “reminderTime:* -reminderDoneTime:*”;`
Continue reading

\DateTime class is cool.

Yeah, it is.

Do you want yesterday at 6 am? `new \DateTime(“yesterday 06:00:00”);`
Do you want two weeks ago at noon? `new \DateTime(“-2 weeks 12:00:00”);`
Do you want just 2 minutes ahead? `new \DateTime(“+2 minutes”);`

`\DateTime` class parses string given in the constructor and translates it into valid date and time. It is awesome when you have to compute intervals for SQL query. Continue reading

PHPyths Buster: Evernote SDK [update]

It’s time to do some Evernote configuration.

To write an application that needs connection with Evernote I need a developer account. I have one, so in fact, you need it 😉

Credentials

Go to https://dev.evernote.com/doc/ and click “Get an API key” button and fill the form with your data. You’ll get Consumer Key and Consumer Secret needed to connect with Evernote.

Now I suggest you create a test account in https://sandbox.evernote.com/. It allows you to test your application using test account so you won’t mess up your real notes.
Continue reading

PHPyths Buster: Basic application

Ok, we have installed environment, everything works fine so we can start creating our app!

As you may remember I want to write simple application extending Evernote by simplify displaying reminders and do some daily action on some specific notes.

I’ll start with displaying the notes. By now I don’t need connection with Evernote itself, so I’ll create some dummy notes in PHP.

The model

Let’s start with the model for note. Model is the special type of PHP class which describes all data for the note. I need for sure: `id`, `title`, `description`, `remind at` date and maybe `created at` date. It is enough for now if the application will require some more information I’ll add it to the model. Continue reading

PHPyths Buster: Hello World!

I hope, that setting up the environment goes ok 😉

In this post, I want to show you how to install Symfony on previously prepared docker container.

Installation

The simplest way to install Symfony is to use composer. Symfony has it’s own installation script, but I think that composer’s one is just fine.

If you have composer installed then it’s enough to call `composer create-project symfony/framework-standard-edition code` in your terminal (in the main directory of a docker, where `docker-composer.yml` file is placed, see PHPyths Buster: Project environment). All required packages will be downloaded and installed automatically.
Continue reading

PHPyths Buster: Project environment

Ok, time for some action!

I’ll start the project by setting up the environment. As mentioned in the previous post, I want to use Docker to simplify configuration for everyone who wanted to create this project with me 😉

I’m not a docker expert. In fact, a basic configuration for this project took me about 2 days! I could not find ready to use configuration so I had to create it myself using 2 or 3 different configurations.

But finally I made it, and I proudly present it to you! It is very simple and you might be surprised what took me so long 😉

Continue reading

PHPyths Buster: The Project

As promised I’m starting with a real project to proof that PHP may be what you want to build a web application 😉

Objectives

I want to show you complete way to build the functional application. I’ll go from setting up the environment, through installing the framework and required libraries, to deploying to the server.

Environment

I’ll use Docker with Nginx, MySQL, and PHP7 – I want you to make a minimal effort to start the project. In addition, you won’t need to install something on your computer (well, except Docker itself) and your computer will be clean as always. You could also do the examples yourself and easy experiment with the code in the same environment. If something will break you could always let me know and we’ll fix it together 🙂
Continue reading

PHPyths Buster: Deployment

Let’s talk about deployment.

The past

Several years ago when I wanted to deploy an application I did it using FTP. Filezilla was the best friend. When some feature was ready I connected with the server, copy files into proper locations and it was it. The application simply used new files from the next request.

Easy? Not at all. It was annoying to connect the server, find directories and copy new files. It was very easy to make a mistake and copy file into the wrong directory.

And it was in times when I don’t even know that version control systems exist! That means that I have the newest version of edited files on my computer and on the server only. When I worked on a project alone it was “only” risky. But I remember one project on which I worked with 2 other people in the same time. You know what it means, don’t you? 😉
Continue reading

PHPyths Buster: A few words about importing classes

Thanks to this series I’ve made a time travel. Travel to my first experiences in PHP, which were my companion for about two and a half years.

Old, custom framework times

I remember when I was creating a web application in our own framework. It was barely object oriented, had a couple of files with over 5k lines and used pure MySQL queries to retrieve data. Classic 😉

In those times if you wanted to use some external library or even your own class – you used `include` or `require` to attach it to the current file. I did it that way for a long time. And that was a nightmare.
Continue reading

PHPyths Buster: PHP is ugly as s**t

PHP is easy to start with. The web page is the easiest and fastest way to see progress. And that’s why PHP is often chosen as the first programming language. In fact thanks to PHP I’ve started to work, but it’s another story 😉

The beginning

Many newbie programmers started with something like that:

<?php
$name = $_GET["name"];
if ($name == "") {
    $name = "Stranger";
}
?>

<html>
<head> 
  [...] 
</head>
<body>
  <h1>hello <?php echo $name; ?></h1>
</body>
</html>

It’s fully functional web page! And It’s all right to start like this, but it’s very wrong to continue coding like this. Mixing HTML and PHP is just wrong (ok, PHP might be used as a template engine and I will cover that later). I think that many people call themselves “PHP programmers” after that and it’s probable source of the shortest joke in the (programming) world – PHP programmer 😉

Continue reading

« Older posts Newer posts »

© 2024 Krzych Jończyk

Theme by Anders NorenUp ↑