 Sebenarnya saya belum berjaya di pejabat kerja. Jadi jika anda ada laptop dan segalanya, anda boleh bincang saya di pejabat ini. Jadi beri saya, saya belum berjaya di P.H.P. sekejap. Bagaimana dengan P.H.P. Tuan? Baiklah, masih ada beberapa lembongan di sana. Baiklah, baiklah. Bagaimana dengan Tuan? Bagaimana dengan P.H.P. Berhenti. Bagaimanapun... Bagaimana dengan P.H.P. sekejap? Baiklah. Bagaimana dengan P.H.P. sekejap? Baiklah. Jadi, anda mahu berjalan di pejabat ini. Anda dapat melakukan begitu dengan... ...buka teksan anda dan meletakkan. Jadi ada Wi-Fi yang dikenalkan. Jadi anda dapat menggunakan network Wi-Fi yang dikenalkan. Dan anda dapat berjalan bersama kami. Baiklah. Jadi, kedua ini adalah mengenai memulakan P.H.P. 7.2. Jadi, hanya sebuah kota tangan. Berapa banyak anda melihat? Saya melihat menggunakan P.H.P.5. Baiklah, 5. Jadi, ia akan berpunyak 5.6. Pada masa terakhir. Pada masa terakhir. 7.000. Bagaimana dengan anda? Sudah ada 7.000. Bagus. 7.1. Baiklah, 7.2. Pada masa terakhir. Baiklah. Baiklah, baguslah. Baiklah. Jadi, untuk pejabat ini, saya akan melakukan dengan cepat bagaimana untuk menggunakan P.H.P. 7.2. Saya rasa Fujibora telah menunjukkan keadaan yang sangat enak semasa anda memulakan P.H.P.5. dan kemudian menggunakan P.H.P. 7.2. Tetapi sebenarnya, jika anda pergi ke P.H.P. jika anda pergi ke P.H.P. yang adalah tempat yang anda dapat menemukan dan memiliki semua pembunuhan dan pembunuhan yang dikatakan di public.darka.containers. HUB.darka.com Jadi, ini adalah semasa anda dapat menemukan semua pembunuhan yang dikatakan di public.darka.containers. Dan anda pergi mencari P.H.P. yang adalah pembunuhan di public.darka.containers untuk P.H.P. Jadi, dengan ini, anda dapat menggunakan versi-versi P.H.P. yang anda buta. Sebenarnya, untuk mencari, jika anda sudah memulang dalam perubahan yang dikatakan di container seperti di ECS atau jika anda memulang pembunuhan atau sesuatu yang sudah mempunyai perubahan yang dikatakan di container anda dapat sebenarnya membuat pembunuhan yang dikatakan dari satu dari mereka. Jadi, pembunuhan yang dikatakan anda dapat memulang dengan P.H.P.7 atau P.H.P.5. Jadi, ini akan menjadi cara yang sangat baik untuk anda membuat beberapa test untuk anda lihat bagaimana proyek anda atau pembunuhan yang dikatakan di P.H.P. P.H.P.5 atau P.H.P.7 jadi anda dapat menggunakan ini sebagai cara memperkenalkan dengan versi-versi yang berbeza Jadi, saya mengingatkan yang anda lihat dengan P.H.P.5 anda lihat dengan P.H.P.5 kerana anda mempunyai syarikat yang digunakan atau tidak lebih mendukung dalam P.H.P.7 anda betul tak? Anda menghargai untuk memperkenalkan P.H.P.7 kerana anda pasti apa yang boleh atau tidak akan berubah betul tak? Baiklah, jadi dengan cara ini, saya harap anda dapat menggunakan ini sebagai cara memperkenalkan pembunuhan anda sebelum anda bahkan memperkenalkan versi-versi P.H.P.7 Jadi, untuk ini kita akan memulai dulu dengan menggunakan doktor dan apabila anda mempunyai doktor anda dapat sebenarnya memperkenalkan kawasan ini dan anda juga minta maaf untuk memperkenalkan P.H.P.1 Jadi, ada pembunuhan P.H.P. yang mempunyai semua perkara ini anda akan ke pembunuhan P.H.P. anda akan mencari link saya mencabar link ke pembunuhan P.H.P. yang bermula dengan P.H.P.7.2 Jadi, di dalam sini ada file doktor jadi, seperti yang anda bincangkan file doktor, file doktor adalah pembunuhan P.H.P.5 yang beritahu anda bagaimana yang harus diperkenalkan jadi, saya sebenarnya memperkenalkan pembunuhan P.H.P.7.0 dan CLI jadi, ini begini pembunuhan P.H.P.1 seperti pembunuhan P.H.P.1 jadi, tidak terlalu terlambat hanya pembunuhan P.H.P.1 dan apa yang saya lakukan di sini adalah memperkenalkan pembunuhan P.H.P.1 yang memperkenalkan pembunuhan P.H.P.1 bagaimana anda mempunyai pembunuhan P.H.P.1 dan P.H.P.1 dan P.H.P.2 jadi, ini seperti P.H.P.1 yang dipunyai pembunuhan P.H.P.1 saya rasa pembunuhan P.H.P.1 juga adalah pembunuhan P.H.P.1 yang memperkenalkan pembunuhan P.H.P.1 P.H.P.1 P.H.P.1 saya rasa pembunuhan P.H.P.1 jadi, ini akan membuat anda mengambil pembunuhan P.H.P.1 dan menggunakan kodin jadi, kita cuba mengawal pembunuhan P.H.P1 folder. It's a font clear. So the first thing you do is once you've checked out the code, you run this command docker build which basically builds your container with the necessary basically docker file which is the docker.cli. So this command will basically build a docker container with a name getting started slash cli. That's a tag name and where is the root folder. So I'm going to run this now. It's going to build a docker container. I've actually built this last night so it kind of ran really fast. So what I've done here is I created a docker container. So if I do a docker image, it will show me all the docker containers that I've actually built and you'll find that there is a docker container here which was just built 21 hours ago but yes, I actually ran it again so it's kind of the same. Are you guys, anyone here following along? I mean, calling along with me? No? Quite a few. Okay. So once you have this, you can then run the command which basically starts off your docker container in an interactive mode. So you have a docker run dash it, it sensual interactive and t sensual. You start the terminal and I give it a name and I'm starting the specific container which I just created. Okay. So I'm going to run that now. Right. So this puts me in an interactive shell. So you see at the bottom here, this is actually supposed to be an interactive shell. So if I type PHP info, you put, ah, no, doesn't. PHP info, sorry. Aha. Sol of. Let's try this again. PHP info. So always remember to put a semi colon. Yeah. So it basically tells you what you would see in PHP, when you try run PHP info in the TTY environment like this. So it tells you all the stuff that's here. So you can echo hello world. Right. So you use this as an interactive way of doing it. So the exit, just type exit and you basically get out of it. Right. So that's pretty much it. And the second thing we want to try is to run a docker container with Apache. So I'm going to build another container. This one is a different file name. It's docker file to Apache. So I run this. You prepare a docker container. And then I can run the docker container now. So it's basically docker run with the specific name. I'm mapping the port number which is port 8080 on my host machine to port 80 inside. So it basically run this container. Let me show you the file first. So, right. So this is the docker file that I'm going to run. Which basically runs PHP 7 with Apache. Oh, actually should be 7.2. Okay. Never mind. Let's try this. Should be 7.2. Okay. Let's try to rerun 7.2. Right. So with this, I should be able to create a new container. Docker build again. And it should download PHP 7.2. Oh, okay. Right. So this is specifically what happens when it downloads PHP 7.2. Oh, what's going on? 8. 8. Mcrip. Oh, yeah. Okay, maybe I shouldn't be using this. Oh, they change. They change how Mcrip works in 7.2, right? They don't bundle anymore. Okay. Yeah. Okay. Oh, well. Okay. And just remove that for now. So I'll just be building a container with 7.2. And I'm going to try and run it. I'm going to try and run it now. Okay. So I just ran it and then basically it's running in the background. So with a dash D, even put a dash D, when you try to run a container, it actually starts it and puts it in the background. So it can get back into the shell. So it will type docker ps, which shows me what are the processes running. It tells me there's actually one container running in the background right now. It's the same to port 80. It's mapped to port 8080 on my local machine. So if I open that in my page now, 8080, it says hello world. At the same time, as I map this, as I map this, I also map my current folder, the SRC folder. So SRC folder is also mapped into VAR www.html, which is where Apache will host the website. So if I open that page right now, over here. So here is a simple file. So let's change this to marry my name. And I try and reload that page. It should then show my name. Quite simple. So in the GitHub page, I actually added some links to some two blog posts, which I found, which actually shows sample code, which will only work on, which will show it about the new features in 7.2. I'll just show you one of the blog posts. So this one talks about the core improvements. So core improvements in 7.2. First of all, the type hinting. Now, when you write, when you create a function and you put type, we have been able to do type hinting for a while. But in 7.2, they also introduced the object as a type you can do type hinting on. So in a sense, you can pass in any object into it and it should work. So in the case, for this example here, there's two classes. So in this case, it tells me this function test can then take in an object which is either of first class or second class. So either one of them should work. So I can try and copy this entire piece into the PHP file and run this again. So it says my name is Jim, my name is John. So it should run for both. Even though it's saying it's taking an object, although I'm curious, will you still work if I don't extend from the same class? Will you still work? Let's try. Okay, still work. So it doesn't actually need to be extended from the same class. May I be? May be. Okay, cool. So, yeah, any questions so far? Oh, good. Just for fun, just for fun, I'm going to try and create new another container and I hope this works. So I'm going to create another container. This time round, instead of using 7.2, I'll try run this container now with 7.0. So what it was before. I'm going to try and build it again. Right. So this is, this container is now built with 7.0. We're trying to run that piece. Oh, it still works. Oh, I didn't run it. Sorry, I didn't stop it. I should stop it. Right. It stopped and I got to run it again. This should be running 7.0 and it shows an exception. So, yeah, this is just to show you that you're able to test your code both in a 7.1 or 7.0 environment and then switch it up back to 7.2 and see how that will affect your code. Right. Can two docker containers share the same share folder? You can. So basically you can run two. Because it's just mounting your folder. You're just mounting your SRC folder into the container. So I will, let me try and... Okay, so let's, we'll do the experiment now where we have one container. So, this first container that we built is 7.0, right? And so, let's say... Stopper PS. So, we have one container running right now that listens to port 8080 and this is running PHP 7, correct? So, let's try and create build a new container. So, I will use the same container to build container command. So, instead of... So, here I'm building a new container. Let me change the code first. So, I'll change it to 7.2 here. And then I'm going to build a new container. Maybe PHP Apache 7.2. Okay. So, this will build a new, a different container which is using a tag PHP Apache 7.2, right? So, now I have... So, if I do docker images which shows you all the images that are built, you'll see there's one which is some PHP Apache which is 7.0 and one which uses PHP 7.2. So, if I now run the... run the run command with 7.2 and instead of mapping to port 8080, I'll map it to port 8081 which give it a different name or so, so it won't clash. Right. So, if I do docker ps, you'll see that there are two docker containers running right now. One listening to port 8080 which has PHP 7 and docker container of listening to port 8080.1 that runs PHP 7.2. Right. So, let's hopefully experiment works. So, again, once again 8080 because running provision 7 it doesn't see this it won't work. That the type hinting with object won't work. And... Can you hand me click? Yes. Just click any one or two. Let's be higher. I don't know. I might just go walk closer there. Sorry. Okay, then so I'll try and run again localhost 8080.1. Right. So, it's now running PHP 7.0. This is running 7.2 which actually that function works. So, just for kicks I mean I can always change it up a little bit and just run PHP info just to prove to you that it's actually I can run both live like this is 7.6.2 and this is you try again walk closer to towards the door glass door. Ya, so Ya, so 1 running 7.0 or 1.7.2. Ya. Does it make sense so far? Okay. So, let's look at another code sample which is which shows some new features in 7.2. So, return type Right. So, object return type declaration. So, other on top of return of type hinting using objects you can also declare the return type as well as an object. So, again this this sample code here we just copy that into the into the PHP file. So, let's see how this so basically this is my class creating my class and you and you passing it to a test function which takes in arcs and also returns objects. Right. And basically you will basically just contrivedly just return the object that you that you were looking for that was inside there inside the class rather so far. Right. So, if I run this in a PHP 7.0 environment Ya, it shows me there's an error here. So, you know because object is not supported in 7.0. You try and run this here shows up okay. So, you can have one folder mounted on two containers. Right. Each running different version of PHP then use that at the same time to kind of test how your code will run on either one of the versions. So, it will be very helpful if you're doing testing and doing migration of your code from one version of PHP to the next version of PHP. Right. I think I used to work in a startup where they will for a very long time they were still running PHP 4 this is in 2012. 2012 it's not it's not that recent but it's quite far quite long ago we had 18 web servers running PHP 4.0 something I can't remember. No sorry it was 5.1 5.1 so we and then we were like oh there's 5.3 out now should we migrate but we were quite afraid that there's something might break even though we have test coverage some test coverage and so a bit of manual testing that we have tested on some staging servers which was using 5.3 we were still quite fearful of moving to 5.3 right so which is kind of like yeah. So anyway with something like this you make it a lot easier for you to do testing on either versions of PHP yeah so let's try and look at another code example parameter widening this all a bit more deprecation deprecation of code okay deprecation anyway both articles are quite quite extensive this one is just goes into three top top the top few features and in in the other blog post this one actually has a lot more code samples which shows you the difference and new things they will introduce in in 7.2 it covers a few same some first few things which are quite similar one thing that kind of surprise me was this one so if you do unquoted text like this in PHP and i think before PHP 7.2 you just puke and kind of like say you don't i don't know what's going on with test right with 7.2 7.2 it probably shows different error but at least okay yeah so build notice from change from notice to warning lah which is actually quite interesting i thought it would show an exception altogether but actually doesn't so right so okay so remember quote quote your text quote your strings yeah so both articles are pretty extensive you should check them out and if you are yeah so and the sample codes again are hosted on i on my on my github on our github page so you can check that out as well so you can use the second one to run Apache everyone just test in the command line can run the first first one right and of course i'll show you now how to stop your containers because right now it's been running in the background i've got two containers running docker ps which shows me two containers i can stop them by referring to docker stop and i referred to the container id which is the first one or i could refer to the name which i use to start it which is in this case was php my my php papachi docker stop yeah we should then stop both containers how many of you guys actually already using docker in your development environment or your test your test environment just production anyone in production using docker already no okay so yeah it's still a little feel a bit iffy there are some there are a lot of gotchas when you're using docker for one thing your file system is not always going to be there you know your docker containers when it dies it kills it removes all the files from your file system so be cut be careful so what i've done here is i've actually mounted a folder from my whole system into the docker container so the files that i save will still persist or rather i can write write code outside and then it will still be there but that's for testing if you go into production you need to have what you call a mounted you can create you can create volumes you can create volumes in docker which would then become like a folder or you can even mount an NFS network file system into it but as especially for files that you don't you want to to save right like save for example your uploading images into into your your php server you want a folder which is actually shared or stored that can will persist so so basically you use you can use things the NFS or you can even use S3 for example to save your files right so there's a few there's a few more gotchas that might be of interest to people so if you're using docker docker of course you have more experience with docker than me i hope you can share about this in the next in the future php meetups right so i hope i think you guys have any questions any other questions about this tutorial yeah php images of docker is is it minimum minima minima php installation or full stack installation yes it's a minimum installation if you look at the docker you look at the documentation to install additional stuff so let's go further down with pachi without pachi okay right installing more php extension so you can just go through this you can essentially there's some example code here which is actually meant for f php 7.0 so basically you do the installation and use docker php extension install and this basically helps you install the extension you need even even pcl extensions can be installed this way as well so if you're your php installation requires plugins or extensions they're not on not on the base installation you should use this to kind of prepare them so you what what you do is you have your own docker file which basically declass and you just put additional run instructions which will install additional software that you need in your container right once you have that once you've done that and you build the container the container will now have that it will be in that state forever as you always have that those files inside there until such time when you rebuild it or add new things to it right so this will be a very good way to creating an image that is constant and then can be shared with anyone in your development team so it's an example all you need to do is have a one copy of docker file that is shared for your entire development team so everyone just all you need to do is just run build the container and run it locally or you can actually have have a centralized place so what we do SP is that we have a Jenkins server that basically checks out the docker file builds the docker container and push it to a registry so you can push it to docker hub which you can then download and make it run on your local machine so all your developers in your team can always have the latest version of the docker the docker image right which you can then use to to run your code right very good thing and if you want you want to go even deeper like someone just asked about using databases of this right so one way you can do that is that you can include instruction on how to install Postgres or MySQL into your docker file that's one way you can do docker couples correct which is what I'm getting to so the second part is you can orchestrate multiple containers so what is recommended in the docker world is that each docker container should only run one process so you should just spin it up and you should only run Apache you should run Avengin X or you should run MySQL right and nothing else right so essentially you could actually run multiple containers one running the MySQL database run one running Apache and you make them two talk to each other so basically the Apache instance can then connect to the database on the other side so do this you can do you can spin up manually like what I did I spun up to the container just by running command line or you can use system called docker compose so docker compose is a a YML file which basically you can you define everything that you want to run both containers or many containers at the same time right so docker compose file looks a bit like this so let's show you the example with wordpress so right so so this is how it roughly looks like so first of all it tells it what are the services that you need in this case it's a database and the other one is a wordpress container and basically tells you tell it that my db wordpress container should depend on the db container and is the image that remember in the docker file we are tell it which image is which image it builds from so all docker files all all docker containers start from somewhere they originate it's kind of inheritance class inheritance you all your all your objects all your classes inherit from another class right so the same thing applies to docker containers docker containers inherit from another base container right so in this case we're in this this container here is inheriting from the wordpress container and the one up here is inheriting from my php my my sql container right so when you we do this you just all you do is write is have this file in your folder and you run docker compose up right docker dash compose up and you basically spin up both the containers at the same time and they are then connected to each other to they're basically sharing the same network address right so that's the bit more advanced topic which probably I wouldn't cover here but if you're interested in that we can I can probably talk about that in the future meet up right so yeah any other questions cool right and i think all containers can also be one EC2 yes so basically what you can do is you can spin up one EC2 instance and then run docker inside once you have a docker demon you can just spin up multiple instance or inside there but the problem is the port mapping so basically you need to make sure the ports are mapped to the correct place like right now I'm I'm I'm right now over here I'm mapping port 8080 and port 8081 to the to two different instance right you're running on production you want some way of like mapping like a particular URL right like say website 1.com will map to container 1 website 2.com maps to container 2 so that's actually outside of the scope of docker so docker doesn't handle that for you right so for that you probably want to have like nginx or apache server that does reverse proxy that will forward all request to the container 1 or request to container 2 so we have virtual host vhost 1 that that forwards all request to port 8080 for example and then vhost 2 that port maps that forwards all request to reverse proxy to different container which probably at localhost.8081 for example you can actually run the reverse proxy for the docker container you can also do that yes but then your docker container needs to then listen to port 80 yeah okay so you can then basically instead of running apache on your on your host machine your to do this port mapping and sorry the the routing you can actually spin up one docker container that listen to port 80 to act as a main web server which then forwards to the rest so this is a bit of a hacky this is a bit of a hacky solution is is there are ways to work around this there are actually other other software that actually helps you deal with all these things as well one that I have used in the past is this thing called docku so docku is platform as a service think of it as Heroku but running on your local machine and then you can use you can use and you run docker behind the scenes it spins up docker containers behind the scenes right so docku is one of the so it actually spins up docker it creates docker and it also has an engine X server that actually acts as the reverse proxy and basically all this runs in one Linux machine right so which is very cool we really need to like run multiple apps on the same machine this is one way of do it doing it there are other ways of doing it as well you want to go full out into docker into docker world there's also another thing out there called Kubernetes which is think of it as docker but on steroids so it's a there's a lot more power it's a lot more powerful so i wouldn't want to go into this unless you really want that power right but you're just still testing and working and experimenting with this you can start first with just plain docker and or you can use docku which is another option right or you can use docker docker compose there's another way to do it yeah any other questions cool yeah actually that's all i have thank you