Krzych Jończyk

Modern PHP, soft skills, productivity and time management.

Tag: PHP (page 1 of 2)

First attempt to Selenium and PHPUnit

This is a simple tutorial how to set up Selenium test with PHPUnit and phantomjs for easy and fast testing.

Today I wanted to learn something about Selenium. It’s very popular testing tool for any application that can be launched using a web browser, regardless of programming language or technology. I don’t know it very much, in fact, I know only how to set it up and write the simplest test 😉 But I want to share my today’s experiences because I cannot find any simple tutorial and had to glue together scripts, setting and libraries from all across the internet 😉

If you don’t like reading tutorials and want rather dig into example code I created the repository on GitHub where you can find everything I talk about here.
Continue reading

How to start developing in Symfony with only PHP installed?

This blog post will contain useful information for those, who want to start developing in Symfony without setting up a server (like apache or nginx) or installing docker.

PHP from version 5.4 has built in server. You can run it by executing in console php -S 127.0.0.1:8000 in your projects directory. When you go to this address (of course you can change the port and 127.0.0.1 to localhost) you’ll see the main page of your project.

Continue reading

PHPyths Buster: A great string performance test! (updated)

I was challenged in my last post to deeper check performance of strings. I think it will be quite interesting to test out some cases and say which way of using strings is the best.

In this post, I will check several string usages in PHP 5.6 and PHP 7.

To simplify testing I created a simple function which gets 2 arguments: an array of callable functions to compare (as many as you want) with names to display in summary, and a number of loops to test the function…
Continue reading

PHPyths Buster: Single quotes are faster than double quotes

As you may know, in PHP you can use single and double quotes for strings. These two lines are equal:

The only difference here is handling variables placed inside quotes. Let’s look at this simple example:

As you can see in double quotes variables are processed and in single quotes they aren’t.
But which one should I use?
Continue reading

PHPyths Buster: The power of simple CLI modes

If you know Python you know, that it has an interactive shell. The same as javascript, perhaps ruby and many many other languages. But did you know, that PHP has it also?

php -a

php -a command opens interactive shell in which you can write some simple samples of code and quickly validate some of your ideas. It works like Python shell and you can write in it simple statements, functions and so on.
Continue reading

PHPyths Buster: Annotations

I was working on a project in C# and ASP.NET MVC once. It was a long time ago. I can remember how happy I was. Earlier I was creating a project in PHP in the worst way: on an own framework. It was all old, shitty PHP. With big routing arrays, custom validation services, and ancient template engine, Smarty2.

When I started to create a project in ASP.NET I was astonished how many great features it has. One of them were annotations.
Continue reading

PHPyths Buster: End of the project

Time to speed the things up!

The series becomes a little too long, so its time to the drastic movement.

The application is working now. Here I’ll describe how to add a new note and set reminder as done. I think, that this will be a good foundation for extending the application.
Continue reading

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

Older posts

© 2017 Krzych Jończyk

Theme by Anders NorenUp ↑