Learning languages has never been so easy! Let the php tutorial show you how to create your website based on object-oriented programming.
You can expect a php tutorial on object-oriented programming - basics and practice.
With all my heart: Welcome to the course! Here is an overview of what you can expect.
Let's start by setting up your development environment. You can find the necessary software here.
Which editor is the right choice for the examples? You can find the answer here.
I work with PhpStorm in the course. In this lesson, I will show you how the examples can also be opened with other editors.
Are you already fully motivated? A little more after this video. A preview of the practical project.
Some things have changed in php 7. Here is an overview of some of the most obvious changes.
To make the basics chapter even more exciting, you can fill in a cloze text here. Download the template, print it out and edit it as you work through the chapter.
This is where you lay the important foundation, because objects are not just a collection of data and functions. An important introduction to the topic.
When talking about object-oriented programming, sooner or later the term "class" comes up. But what is it all about?
Data encapsulation is an important basic principle. In this lesson, you will learn about the idea behind it.
Without abstraction, your software would very quickly become rather confusing and the desired simplification would not be achieved. Watch this video and learn to think more abstractly.
Inheritance also supports the architecture of your software. Learn to understand it and use it consciously.
Polymorphism is best understood in practice. Nevertheless, you should at least have heard of it at this point.
Have you filled in the cloze conscientiously? Very good! You can now check it here.
From theory to practice. This is where you get started with the implementation of php.
A class is the blueprint for objects. In php, an instance is created with the keyword "new". You can learn how to do this here.
The properties of a class describe the object in more detail. Get to know this concept better.
The constants are an additional option for storing static values. You will also learn about this principle here.
There are some generally accepted conventions or "best practices" for naming variables & co. And that's what we're talking about here.
Are you familiar with the "PassByValue" and "PassByReference" principles? They are extremely important when working with objects. Find out why here.
The first introduction is over. Deepen your knowledge with the first exercise.
You can find a possible solution to the task here.
Now you will learn the basic syntax for declaring functions.
Methods only become truly dynamic through parameters. You will also get to know these here.
Methods can do more than just execute source code and generate output. Here you will learn how values are returned to the caller.
You can store the method name in a variable before the call and continue to use the variable. Get to know this here.
There are different areas of validity that you should know. Get to know them here.
The next exercise is coming up. This time, the topic is "Methods".
The possible solution to the exercise on methods can be found in this lesson.
When working with objects, the reference to the current object ("$this") and the reference to the current class ("self") play a special role. You will learn about both here.
You can execute your own logic when creating and destroying objects. The constructors and destructors are used for this. Get to know the principle here.
Get to know the syntax for inheritance in php here.
If you inherit from a class, you can use the keyword "parent" to refer to the main class. I'll show you how to do this here.
Visibility is of central importance. Get to know the keywords "public", "private" and "protected".
Visibility does not only refer to properties. Here you also transfer the knowledge to methods.
Interfaces are an important stylistic device. In this lesson, you will look at them using an example.
Static methods also play an important role in our practical example. Learn more about the concept here.
Abstract classes and methods are another stylistic device for software architects. You also need to get to know them.
A method may no longer be overwritten? Then make this visible with the keyword "final".
Deepen your work with objects a little more in this exercise.
Here is the solution to the exercise.
When objects are stored in text form or transmitted over the network, this is called "serialization". Learn how it works.
Serialization does not always work properly, e.g. because a connection is not automatically re-established after reading in again. Learn how you can also intervene here.
The magic method "__invoke" allows you to call up your objects directly.
A widely used method is the readable description of objects using the magic method "__toString". I will introduce you to this in this lesson.
Especially with a dynamic data model, you can use magic methods such as "get", "set" etc. to save work. save work. You often find this in practice and you need to know the technology behind it.
For example, certain classes are often checked in conditions. The keyword "instanceof", which you will now learn about here, helps you to do this in php.
Newly introduced in php 7: anonymous classes. They can avoid unnecessary overhead in some situations. You can find a practical example in this video.
A copy of objects cannot be created via the variables. Only the reference is passed on. However, you can clone objects. Here you will learn what is necessary for this.
Exceptions are important in the object-oriented world, as error situations can be passed on across several levels and processed in the appropriate place. Learn to use them.
Also new in php 7: type hints for scalar data types such as "string", "int" etc. Learn how to use them here.
Also new in php 7: the declaration of the return value of a method. Here I present the syntax for this.
So far, the examples have been very simple. In practice, the structure is more complex. This is where the autoloader plays a central role. Learn how to store it.
In this lesson, you will lay the foundations for a clean project structure.
The project structure is now being fine-tuned thanks to the namespaces. Get to know them here.
Would you like to use classes from other namespaces? Learn how to import them here.
Only one instance of a class is created using the "singleton pattern". You can learn about the implementation here.
Do you want to read all data from your own collection or class? An iterator will help you.
An observer enables a very loose coupling between different parts of your application. Get to know this design pattern now.
A factory creates instances of your classes. This minimizes dependencies and centralizes the calling of your constructors.
Get to know the Model-View-Controller pattern before we dive into the practice.
What happens here? Fill up on motivation and take a look at the end result in advance.
A feature of our application: the central entry point. Here you provide the necessary framework conditions via the ".htaccess".
The URL processing and assignment of the correct class runs via bootstrapping. You create it here.
The requested resource is assigned to the controller and an action.
After the resources can be requested, you must of course also offer some. And this is exactly what happens here: via your first controller including action.
A database structure is the necessary prerequisite for further use. It is now being prepared.
In php 7, the "mysql_*" functions no longer exist. Here you will get to know an object-oriented alternative: PDO.
The appearance is of course still determined by HTML/CSS. Here you will learn how the integration can be realized.
The design for the gallery view is taken from the template and then integrated.
You will find a centrally accessible base URL in most frameworks. It can be configured, for example, or specified separately for protected pages such as the log-in (possibly with https). Learn how this can be implemented.
You have already become familiar with the "Factory Design Pattern". It is now also used here.
A model is required before users can be loaded into the application. And this is exactly what is created now.
Sessions are also supported by the gallery. The first step here is to implement the log-in.
Are you logged in? Would you like to log out again? Both functions are checked in this lesson.
The log-in has failed. Here you will learn how to read values from the session.
Another feature, new controller: process forms. This is where you make the preparations.
The upload must also be processed after the "POSTRequest". You will learn all the necessary steps here.
A new image has been successfully transferred. A reference to this is recorded in the database.
Here you will learn how to manage the messages in the session even better.
The uploaded images are scaled to a common denominator (same height).
The practical example is extended with a user login exercise.
You can find a solution for task #4 here.
The strengths of the MVC architecture are utilized and another controller with a different template is used for the same database logic.
The previously very static routing is optimized once again - with its own configuration file.
The adapted routing solution must now be taken into account in bootstrapping.
In order to be able to use the API, the images are uploaded via an iOS app.
Comment now „PHP Tutorial - object-oriented programming: basics & practice“