Chapterبەش 2 · Lectureوانە 2.1
XAMPP: Your Own Local Web ServerXAMPP: ڕاژەکاری وێبی ناوخۆیی خۆت
Install XAMPP, start Apache and MySQL, put your files in htdocs, test PHP with phpinfo(), and create your first PHP project in NetBeans — on Windows (XAMPP) or a Mac (MAMP).
دابمەزرێنە، Apache و MySQL دەست پێبکە، فایلەکانت بخە ناو htdocs، بە phpinfo() PHP تاقی بکەرەوە و یەکەم پڕۆژەی PHPـی خۆت لە NetBeans دروست بکە، لەسەر ویندۆز (XAMPP) یان ماک (MAMP).
What you will learnچی فێر دەبیت
- Explain why PHP needs a web server and what a local server is.
- Name the parts of XAMPP and what each letter of its name means.
- Install XAMPP, start Apache and MySQL, and read the Control Panel.
- Turn a file path in htdocs into the right localhost URL, with the right port.
- Test PHP with phpinfo() and know why the test file must be deleted.
- Create and run a PHP project in NetBeans with XAMPP or MAMP.
- ڕوونی بکەیتەوە بۆچی PHP پێویستی بە هەیە و ناوخۆیی چییە.
- بەشەکانی و واتای هەر پیتێکی ناوەکەی بڵێیت.
- دابمەزرێنیت، Apache و MySQL دەست پێبکەیت و بخوێنیتەوە.
- فایلێک لەناو htdocs بگۆڕیت بۆ URLـی دروستی localhost، بە دروست.
- PHP بە phpinfo() تاقی بکەیتەوە و بزانیت بۆچی دەبێت فایلی تاقیکردنەوەکە بسڕدرێتەوە.
- پڕۆژەیەکی PHP لە NetBeans لەگەڵ XAMPP یان MAMP دروست بکەیت و کارپێبکەیت.
Why you need a local web serverبۆچی پێویستت بە ڕاژەکارێکی وێبی ناوخۆیی هەیە؟
A cannot run PHP. If you double-click a .php file, the browser only shows the code as plain text, or it asks you to download the file. PHP code runs on a that has PHP installed. The server runs the code and sends back only HTML.
ناتوانێت PHP جێبەجێ بکات. ئەگەر دوو جار کرتە لە فایلێکی .php بکەیت، تەنها کۆدەکە وەک دەقێکی سادە پیشان دەدات، یان داوات لێدەکات فایلەکە دابگریت. کۆدی PHP لەسەر کار دەکات کە PHPـی لەسەر دامەزرابێت. کۆدەکە جێبەجێ دەکات و تەنها HTML دەنێرێتەوە.
While you learn, you do not need to rent a server on the Internet. A local web server turns your own computer into a web server, so you can write and test PHP pages at home or in the lab. Local simply means "on this computer". The program we use for this is .
لە ماوەی فێربووندا پێویست ناکات لەسەر بەکرێ بگریت. ناوخۆیی کۆمپیوتەرەکەی خۆت دەکاتە ، بۆیە دەتوانیت لە ماڵەوە یان لە تاقیگە لاپەڕەکانی PHP بنووسیت و تاقییان بکەیتەوە. ناوخۆیی تەنها بەم واتایەیە: «لەسەر ئەم کۆمپیوتەرە». ئەو بەرنامەیەی بۆ ئەم کارە بەکاری دەهێنین .
Before a cook opens a restaurant in the bazaar, she practises in her home kitchen and cooks for her family. The home kitchen has the same kind of stove and pots as a restaurant. XAMPP is your home kitchen: it has the same programs as a real web server (Apache, PHP and a database), but only you "eat" there.
پێش ئەوەی چێشتلێنەرێک چێشتخانەیەک لە بازاڕدا بکاتەوە، لە چێشتخانەی ماڵەوە ڕاهێنان دەکات و بۆ خێزانەکەی چێشت لێدەنێت. چێشتخانەی ماڵەوە هەمان جۆری تەباخ و مەنجەڵی هەیە کە لە چێشتخانەی بازاڕدا هەیە. چێشتخانەی ماڵەوەتە: هەمان ئەو بەرنامانەی تێدایە کە ڕاستەقینە هەیەتی (Apache، PHP و )، بەڵام تەنها خۆت لێی «دەخۆیت».
Where the analogy stops workingسنووری ئەم نموونەیە
A real restaurant serves strangers all day. XAMPP is made for testing on your own computer. Its default settings are not safe enough to put on the Internet for the public.
چێشتخانەی ڕاستەقینە هەموو ڕۆژێک خزمەتی خەڵکی نەناسراو دەکات. بۆ تاقیکردنەوە لەسەر کۆمپیوتەری خۆت دروست کراوە. ڕێکخستنە بنەڕەتییەکانی ئەوەندە پارێزراو نین کە بۆ خەڵک لەسەر دابنرێت.
All-in-one packages: WAMP, XAMPP and MAMPپاکێجە هەمووی-لە-یەکەکان: WAMP، XAMPP و MAMP
To run PHP pages you need three things: a web server, PHP itself and (later) a server. Installing and connecting them one by one is hard for a beginner. An all-in-one package installs all of them together, already set up to work with each other. The lecture names two packages for Windows: WAMP and XAMPP. The lab screenshots use a third one, MAMP, on a Mac.
بۆ کارپێکردنی لاپەڕەکانی PHP سێ شتت پێویستە: ، خودی PHP و (دواتر) . دامەزراندن و پێکەوەبەستنی ئەمانە یەک بە یەک بۆ کەسێکی سەرەتایی قورسە. پاکێجی هەمووی-لە-یەک هەموویان پێکەوە دادەمەزرێنێت و پێشتر ڕێکیان دەخات تا پێکەوە کار بکەن. وانەکە دوو پاکێج بۆ ویندۆز ناو دەبات: WAMP و XAMPP. وێنەکانی تاقیگە پاکێجی سێیەم بەکاردەهێنن، کە MAMPـە لەسەر کۆمپیوتەری ماک.
| Packageپاکێج | Runs onلەسەر چی کار دەکات | Website | What the name meansواتای ناوەکە |
|---|---|---|---|
| WampServer | Windows onlyتەنها ویندۆز | www.wampserver.com | Windows + Apache + MySQL + PHP |
| XAMPP | Windows, Linux and macOSویندۆز، لینوکس و macOS | www.apachefriends.org | X (cross-platform) + Apache + MariaDB + PHP + PerlX (واتە ) + Apache + MariaDB + PHP + Perl |
| MAMP | macOS (a Windows version also exists)macOS (وەشانێکی ویندۆزیشی هەیە) | www.mamp.info | Mac (Macintosh) + Apache + MySQL + PHP |
| LAMP | Linux: the usual system of hosting serversلینوکس: سیستەمی ئاسایی | No single download: Linux installs each part from its package managerیەک نییە: لینوکس هەر بەشێک لە بەڕێوەبەری پاکێجەکانی خۆیەوە دادەمەزرێنێت | Linux + Apache + MySQL or MariaDB + PHPLinux + Apache + MySQL یان MariaDB + PHP |
This course uses XAMPP. Everything you learn also works with WAMP or MAMP. Only two things change: the name of the web folder and the number. You will meet both differences in this lecture.
ئەم کۆرسە XAMPP بەکاردەهێنێت. هەموو ئەوەی فێری دەبیت لەگەڵ WAMP و MAMPیش کار دەکات. تەنها دوو شت دەگۆڕێن: ناوی وێب و ژمارەی . لەم وانەیەدا هەردوو جیاوازییەکە دەبینیت.
What XAMPP isXAMPP چییە؟
is a free, package made by the Apache Friends project. It installs a complete web server on your computer in a few clicks. Because it is , it installs on Windows, Linux and Mac, so the same setup works wherever you study.
پاکێجێکی بێبەرانبەر و کە پڕۆژەی Apache Friends دروستی کردووە. بە چەند کرتەیەک تەواو لەسەر کۆمپیوتەرەکەت دادەمەزرێنێت. چونکە ، لەسەر ویندۆز، لینوکس و ماک دادەمەزرێت؛ بۆیە هەمان لە هەر شوێنێک بخوێنیت کار دەکات.
What XAMPP isXAMPP چییە؟
What the letters X-A-M-P-P meanواتای پیتەکانی X-A-M-P-P
- X – : XAMPP works on Windows, Linux and macOS.
- A – : the actual web server program. It receives requests and delivers web content to the browser.
- M – (in older versions ): the database server. A web application stores the data it collects in a database, for example users, products or messages.
- P – (PHP: Hypertext Preprocessor): a . It is open source, quite easy to learn, and works very well with MySQL.
- P – : an older scripting language. XAMPP includes it, but we do not use it in this course.
- X – : لەسەر ویندۆز، لینوکس و macOS کار دەکات.
- A – : ڕاستەقینەی . وەردەگرێت و ناوەڕۆکی وێب بۆ دەنێرێت.
- M – (لە وەشانە کۆنەکاندا ): . ئەو دراوانەی کۆیان دەکاتەوە لە هەڵیان دەگرێت، بۆ نموونە بەکارهێنەران، کاڵاکان یان نامەکان.
- P – (PHP: Hypertext Preprocessor): . ، فێربوونی تا ڕادەیەک ئاسانە و زۆر باش لەگەڵ MySQL کار دەکات.
- P – : کۆنترە. لەگەڵ خۆیدا هەیەتی، بەڵام لەم کۆرسەدا بەکاری ناهێنین.
What XAMPP isXAMPP چییە؟
The main parts in more detailبەشە سەرەکییەکان بە وردی
Apache is the web server. It waits for requests from browsers. When a request arrives, it finds the right file. If the file ends in .php, Apache gives it to PHP first, and then sends the result to the browser.
Apache . چاوەڕێی دەکات کە لە دێن. کاتێک دەگات، فایلە ڕاستەکە دەدۆزێتەوە. ئەگەر فایلەکە بە .php کۆتایی بێت، Apache سەرەتا دەیداتە PHP، پاشان دەرئەنجامەکە بۆ دەنێرێت.
MariaDB / MySQL is the database server. Many web applications need a database to store the data they collect, such as user accounts or orders. A very simple page may not need one. You will use the database from the Databases chapter on, through phpMyAdmin.
MariaDB / MySQL . زۆربەی پێویستیان بە هەیە بۆ هەڵگرتنی ئەو دراوانەی کۆی دەکەنەوە، وەک هەژماری بەکارهێنەران یان کڕینەکان. لاپەڕەیەکی زۆر سادە لەوانەیە پێویستی پێی نەبێت. لە بەشی بنکەدراوەکانـەوە، بە یارمەتیی ، بەکاردەهێنیت.
PHP is the language of this course. It runs on the server, builds the page, and sends only the finished HTML to the visitor. The visitor never sees your PHP code. You meet it properly in Introduction to PHP.
PHP زمانی ئەم کۆرسەیە. لەسەر کار دەکات، لاپەڕەکە دروست دەکات و تەنها HTMLـی ئامادەکراو بۆ سەردانیکەر دەنێرێت. سەردانیکەر هەرگیز کۆدی PHPـەکەت نابینێت. لە پێناسەی PHP بە تەواوی دەیناسیت.
What XAMPP isXAMPP چییە؟
Where the name "Apache" comes fromناوی «Apache» لە کوێوە هاتووە؟
The course's Kurdish notes start the installation part with: to run PHP, we need the Apache server. Apache is the web server inside XAMPP. Its history in short:
تێبینییە کوردییەکانی کۆرسەکە بەشی دامەزراندن بەم ڕستەیە دەست پێدەکەن: بۆ کارپێکردنی PHP پێویستمان بە ڕاژەی Apache هەیە. ئەو کە لەناو . مێژووەکەی بە کورتی:
- The Apache HTTP Server was created in 1995 by the Apache Group, 21 people from around the world who looked after its development.
- In 1999 the original members of the Apache Group started the Apache Software Foundation (ASF).
- Co-founder Brian Behlendorf first used the name "Apache" for the server. The ASF says the name shows appreciation for the Native American peoples who call themselves Apache.
- Apache HTTP Server لە ساڵی ١٩٩٥ دروست کرا، لەلایەن Apache Groupـەوە، کە ٢١ کەس بوون لە وڵاتە جیاوازەکانی جیهان و چاودێریی پەرەپێدانیان دەکرد.
- لە ساڵی ١٩٩٩ ئەندامە سەرەتاییەکانی Apache Group Apache Software Foundation (ASF)یان دامەزراند.
- دامەزرێنەری هاوبەش Brian Behlendorf یەکەم کەس بوو ناوی «Apache»ی بۆ بەکارهێنا. ASF دەڵێت ئەم ناوە ڕێزلێنانە لەو گەلە ڕەسەنانەی ئەمریکا کە خۆیان بە Apache ناو دەبەن.
What XAMPP isXAMPP چییە؟
Everything XAMPP includesهەموو ئەو شتانەی XAMPP لەخۆی دەگرێت
XAMPP contains more than the five programs in its name. The course summary lists "Apache, MySQL, SQLite, OpenSSL, phpMyAdmin". The table below lists the parts of a current XAMPP for Windows and tells you which ones this course needs.
زیاتر لەو پێنج بەرنامەیەی ناوەکەی لەخۆ دەگرێت. کورتەی کۆرسەکە ئەمانە دەژمێرێت: «Apache، MySQL، SQLite، OpenSSL، phpMyAdmin». لە خوارەوە بەشەکانی ئێستای ویندۆز پیشان دەدات و دەڵێت کامیان لەم کۆرسەدا پێویستن.
| Partبەش | What it doesچی دەکات | Needed in this course?لەم کۆرسەدا پێویستە؟ |
|---|---|---|
| The web server.. | Yesبەڵێ | |
| ("MySQL") | The database server. . | Yes, from the Databases chapterبەڵێ، لە بەشی بنکەدراوەکانەوە |
| Runs PHP code for Apache.کۆدی PHP بۆ Apache جێبەجێ دەکات. | Yesبەڵێ | |
| A web page for managing MySQL/MariaDB databases.لاپەڕەیەکی وێبە بۆ بەڕێوەبردنی MySQL/MariaDB. | Yesبەڵێ | |
| A small database stored in one file. PHP can use it directly, without a server. بچووکە کە لە یەک فایلدا هەڵدەگیرێت. PHP دەتوانێت ڕاستەوخۆ و بەبێ بەکاری بهێنێت. | Later (SQLite)دواتر (SQLite) | |
| OpenSSL | Encryption library used for (port 443). بۆ ( 443). | Works in the backgroundلە پشتەوە کار دەکات |
| XAMPP Control Panel | Starts and stops the servers. دەست پێدەکات و ڕایاندەگرێت. | Yesبەڵێ |
| Another scripting language. ترە. | Noنەخێر | |
| FileZilla FTP Server | Lets other computers upload and download files with .ڕێگە دەدات کۆمپیوتەرەکانی تر بە فایل باربکەن و دابگرن. | Noنەخێر |
| Mercury Mail | A small mail server for testing email. بچووکی ئیمەیڵە بۆ تاقیکردنەوەی ئیمەیڵ. | Noنەخێر |
| Tomcat | A server for web applications written in Java. بۆ کە بە Java نووسراون. | Noنەخێر |
| Webalizer | Makes statistics from the web server's log files.لە فایلەکانی لۆگی ئامار دروست دەکات. | Noنەخێر |
| Fake Sendmail | Lets PHP's mail() function send email through another mail server.ڕێگە دەدات mail()ـی PHP لە ڕێگەی ئیمەیڵی ترەوە ئیمەیڵ بنێرێت. | Noنەخێر |
Installing XAMPP on Windowsدامەزراندنی XAMPP لەسەر ویندۆز
The lecture shows the XAMPP installer one screen at a time. The screens of newer versions look a little different, but the steps are the same. In most steps you can keep the default choice and click Next.
وانەکە دامەزرێنەری شاشە بە شاشە پیشان دەدات. شاشەکانی وەشانە نوێیەکان کەمێک جیاوازن، بەڵام هەنگاوەکان هەمان شتن. لە زۆربەی هەنگاوەکاندا دەتوانیت هەڵبژاردە بنەڕەتییەکە بهێڵیتەوە و کرتە لە Next بکەیت.
- Download and start the installerدامەزرێنەرەکە دابگرە و بیکەرەوە
Open apachefriends.org and download XAMPP for Windows (choose a version with PHP 8). Run the downloaded installer. If Windows shows a message about User Account Control (UAC), click OK: it only warns you not to install XAMPP inside
C:\Program Files.apachefriends.org بکەرەوە و XAMPP for Windows دابگرە (وەشانێک هەڵبژێرە کە PHP 8ـی تێدابێت). دامەزرێنەرە داگیراوەکە کارپێبکە. ئەگەر ویندۆز پەیامێکی دەربارەی User Account Control (UAC) پیشان دا، کرتە لە OK بکە: تەنها ئاگادارت دەکاتەوە کە لەناو
C:\Program Filesدامەنەمەزرێنە. - Welcome screenشاشەی بەخێرهاتن
The first window, Setup – XAMPP, says "Welcome to the XAMPP Setup Wizard". Click Next.
یەکەم پەنجەرە، Setup – XAMPP، دەڵێت «Welcome to the XAMPP Setup Wizard». کرتە لە Next بکە.
- Select Componentsهەڵبژاردنی بەشەکان
In Select Components, choose what to install. Apache and PHP are grey because they are always installed. For this course you need at least Apache, MySQL, PHP and phpMyAdmin. You can leave the other boxes ticked; they do no harm.
لە Select Components هەڵیبژێرە چی دابمەزرێت. Apache و PHP خۆڵەمێشین چونکە هەمیشە دادەمەزرێن. بۆ ئەم کۆرسە لانیکەم Apache، MySQL، PHP و phpMyAdminت پێویستە. دەتوانیت چوارگۆشەکانی تریش نیشانکراو بهێڵیتەوە؛ زیانیان نییە.
The Select Components screen. The third group holds tools, not languages, even though the screen calls it "Program Languages".شاشەی Select Components. گرووپی سێیەم ئامرازە، نەک زمان، هەرچەندە شاشەکە ناوی ناوە «Program Languages».Course material - Installation folderفۆڵدەری دامەزراندن
In Installation folder, keep
C:\xampp. A short folder outsideC:\Program Filesavoids permission problems in Windows.لە Installation folder،
C:\xamppبهێڵەوە. کورت لە دەرەوەیC:\Program Filesڕێگری لە کێشەی مۆڵەت لە ویندۆزدا دەکات. - Bitnami (optional)Bitnami (ئارەزوومەندانە)
Older installers then show BitNami for XAMPP. It offers free installers that add Drupal, Joomla!, WordPress and other open-source applications on top of XAMPP. You do not need them: untick Learn more about BitNami for XAMPP (this box only opens a web page) and click Next. Newer installers may skip this screen.
دامەزرێنەرە کۆنەکان پاشان BitNami for XAMPP پیشان دەدەن. دامەزرێنەری بێبەرانبەر پێشنیار دەکات کە Drupal، Joomla!، WordPress و تر بخەنە سەر . پێویستت پێیان نییە: نیشانەی Learn more about BitNami for XAMPP لابەرە (ئەم چوارگۆشەیە تەنها پەڕەیەکی وێب دەکاتەوە) و کرتە لە Next بکە. لەوانەیە دامەزرێنەرە نوێیەکان ئەم شاشەیە پیشان نەدەن.
- Installدامەزراندن
Ready to Install says "Setup is now ready to begin installing XAMPP on your computer". Click Next and wait. While it copies files, the window says "Welcome to XAMPP! XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl."
Ready to Install دەڵێت «Setup is now ready to begin installing XAMPP on your computer». کرتە لە Next بکە و چاوەڕێ بە. لە کاتی کۆپیکردنی فایلەکاندا پەنجەرەکە دەڵێت «Welcome to XAMPP! XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl.»
- Finishتەواوکردن
At the end, leave Do you want to start the Control Panel now? ticked and click Finish. If Windows Firewall asks about Apache HTTP Server or mysqld, allow access on private networks only.
لە کۆتاییدا، Do you want to start the Control Panel now? بە نیشانکراوی بهێڵەوە و کرتە لە Finish بکە. ئەگەر Windows Firewall پرسیاری دەربارەی Apache HTTP Server یان mysqld کرد، تەنها لەسەر private networks ڕێگە بدە.
The XAMPP Control Panelپانێڵی کۆنترۆڵی XAMPP
You start and stop the servers from the XAMPP . On Windows, open it from the Start menu or run C:\xampp\xampp-control.exe. Each row is one module (one server program).
لە XAMPPـەوە دەست پێدەکەیت و ڕایاندەگریت. لەسەر ویندۆز لە لیستی Start بیکەرەوە، یان C:\xampp\xampp-control.exe کارپێبکە. هەر دێڕێک یەک مۆدیوڵـە (یەک ).
The XAMPP Control Panelپانێڵی کۆنترۆڵی XAMPP
Starting Apache and MySQLدەستپێکردنی Apache و MySQL
The table has five columns: Service (a box to install the module as a Windows service), Module (the program's name), PID(s) (the process number Windows gives a running program), Port(s) (the it listens on) and Actions (buttons). The log at the bottom says that the Control Panel works without administrator rights for most things, but changing Windows services needs them. It also shows the installation folder, c:\xampp.
پانێڵەکە پێنج بەشی هەیە: Service (چوارگۆشەیەک بۆ دامەزراندنی مۆدیوڵەکە وەک خزمەتگوزارییەکی ویندۆز)، Module (ناوی )، PID(s) (ئەو ژمارەیەی ویندۆز دەیداتە کارا)، Port(s) (ئەو گوێی لێ دەگرێت) و Actions (دوگمەکان). لۆگەکەی خوارەوە دەڵێت بۆ زۆربەی کارەکان بەبێ مافی بەڕێوەبەر کار دەکات، بەڵام گۆڕینی خزمەتگوزارییەکانی ویندۆز ئەو مافەی پێویستە. هەروەها دامەزراندنەکە پیشان دەدات: c:\xampp.
Click Start next to Apache.
کرتە لە Start بکە لە تەنیشت Apache.
Click Start next to MySQL.
کرتە لە Start بکە لە تەنیشت MySQL.
Wait a moment. Each module name turns green, its PID and ports appear, and its button changes to Stop. The log shows "Attempting to start Apache app..." and then "Status change detected: running".
کەمێک چاوەڕێ بکە. ناوی هەر مۆدیوڵێک سەوز دەبێت، PID و دەردەکەون و دوگمەکەی دەبێتە Stop. لۆگەکە دەڵێت «Attempting to start Apache app...» پاشان «Status change detected: running».
Apache often shows two PIDs, because it runs a main process and a helper process. The lecture's screenshot comes from version 3.2.1 (2013) and the course deck's from version 3.3.0 (2021). The look is almost the same, and so are the steps.
Apache زۆرجار دوو PID پیشان دەدات، چونکە پرۆسەیەکی سەرەکی و پرۆسەیەکی یاریدەدەر کارپێدەکات. وێنەی وانەکە هی وەشانی 3.2.1ـە (٢٠١٣) و وێنەی سلایدەکانی کۆرسەکە هی وەشانی 3.3.0ـە (٢٠٢١). شێوەکەیان نزیکەی یەک شتە، هەنگاوەکانیش هەروا.
| Buttonدوگمە | What it doesچی دەکات |
|---|---|
| Start / Stop | Starts or stops that module.ئەو مۆدیوڵە دەست پێدەکات یان ڕایدەگرێت. |
| Admin | Apache: opens http://localhost/ (the XAMPP dashboard). MySQL: opens phpMyAdmin at http://localhost/phpmyadmin/.Apache: http://localhost/ دەکاتەوە (داشبۆردی XAMPP). MySQL: لە http://localhost/phpmyadmin/ دەکاتەوە. |
| Config | Opens the module's configuration files, for example httpd.conf (Apache) or php.ini (PHP).فایلەکانی مۆدیوڵەکە دەکاتەوە، بۆ نموونە httpd.conf (Apache) یان (PHP). |
| Logs | Opens the error logs. Read them when a module will not start.لۆگی دەکاتەوە. کاتێک مۆدیوڵێک دەست پێناکات بیانخوێنەوە. |
| Netstat | Shows which ports are in use, and by which program.پیشان دەدات کام بەکاردێت و لەلایەن کام . |
| Shell | Opens a command window where php and mysql commands work.پەنجەرەیەکی فەرمان دەکاتەوە کە فەرمانەکانی php و mysqlـی تێدا کار دەکەن. |
| Explorer | Opens the XAMPP folder (C:\xampp) in File Explorer. XAMPP (C:\xampp) لە File Explorer دەکاتەوە. |
| Services | Opens the Windows list of services.لیستی خزمەتگوزارییەکانی ویندۆز دەکاتەوە. |
| Help / Quit | Help opens the help file. Quit closes the Control Panel.Help یارمەتی دەکاتەوە. Quit دادەخات. |
The XAMPP Control Panelپانێڵی کۆنترۆڵی XAMPP
Ports: 80, 443 and 3306پۆرتەکان: 80، 443 و 3306
One computer can run many server programs at the same time. Each one listens on its own , a number from 0 to 65535. The browser uses the port to reach the right program. XAMPP's defaults are:
یەک کۆمپیوتەر دەتوانێت لە یەک کاتدا چەندین کارپێبکات. هەریەکەیان گوێ لە ی تایبەتی خۆی دەگرێت، کە ژمارەیەکە لە 0 تا 65535. بە یارمەتیی دەگاتە ڕاستەکە. ژمارە بنەڕەتییەکانی XAMPP ئەمانەن:
| Port | Program | Used forبۆ چی بەکار دێت |
|---|---|---|
80 | Apache | Normal web pages (). It is the default, so http://localhost means http://localhost:80. بە ئاسایی. ئەمە ژمارە بنەڕەتییەکەیە، بۆیە http://localhost واتە http://localhost:80. |
443 | Apache | Secure pages ().لاپەڕە پارێزراوەکان (). |
3306 | MySQL / MariaDB | The database server. PHP connects to it in later lectures. . PHP لە وانەکانی داهاتوودا پەیوەندی پێوە دەکات. |
8888 | Apache in MAMPApache لە MAMPدا | MAMP's default web port, seen in the lab screenshots. بنەڕەتیی Apacheـی MAMP، کە لە وێنەکانی تاقیگەدا دەبینرێت. |
8889 | MySQL in MAMPMySQL لە MAMPدا | MAMP's default database port. بنەڕەتیی MAMP. |
Think of a big government office building. The building has one address, but inside there are many numbered windows (counters). Window 80 serves web pages, window 443 serves secure web pages, and window 3306 serves the database. Your computer's address is localhost, and each port is one numbered window.
بیر لە باڵەخانەیەکی گەورەی فەرمانگەیەکی حکومی بکەرەوە. باڵەخانەکە یەک ناونیشانی هەیە، بەڵام لەناوەوە چەندین پەنجەرەی ژمارەدار (کاونتەر) هەیە. پەنجەرەی 80 دەدات، پەنجەرەی 443 لاپەڕە پارێزراوەکان دەدات و پەنجەرەی 3306 خزمەتی دەکات. ناونیشانی کۆمپیوتەرەکەت localhostـە و هەر یەک پەنجەرەی ژمارەدارە.
Where the analogy stops workingسنووری ئەم نموونەیە
In an office, two clerks could share one window. A port can be opened by only one program at a time. If another program already uses port 80, Apache cannot start.
لە فەرمانگەدا لەوانەیە دوو فەرمانبەر یەک پەنجەرە بەکاربهێنن. بەڵام لە یەک کاتدا تەنها یەک دەتوانێت بیکاتەوە. ئەگەر تر پێشتر 80ـی بەکارهێنابێت، Apache ناتوانێت دەست پێبکات.
Learn what a port number is, how it differs from an IP address, and the well-known ports, such as 80 for web servers.
فێر دەبیت ژمارەی چییە، چ جیاوازییەکی لەگەڵ هەیە و ناسراوترین ، وەک 80 بۆ .
Watch 0:00–7:48, what ports are and common port numbers
لە 0:00 تا 7:48 سەیر بکە: چییە و ژمارە باوەکانی .
The XAMPP Control Panelپانێڵی کۆنترۆڵی XAMPP
When a module does not startکاتێک مۆدیوڵێک دەست پێناکات
The most common problem is that Apache does not start and the log says that port 80 (or 443) is "in use" or "blocked". Another program is already using that port, for example Microsoft's web server or another web server. Click Netstat to see which program it is. You have two choices:
باوترین کێشە ئەوەیە کە Apache دەست پێناکات و لۆگەکە دەڵێت 80 (یان 443) «in use» یان «blocked»ـە. تر پێشتر ئەو بەکارهێناوە، بۆ نموونە مایکرۆسۆفت، ، یان تر. کرتە لە Netstat بکە تا بزانیت کام . دوو ڕێگات هەیە:
- Stop or uninstall the other program, then click Start again.
- Or give Apache another port. Click Config → Apache (httpd.conf), change the two lines shown below, save the file and start Apache again. From now on, write the port in every address, for example
http://localhost:8080/.
- تر ڕابگرە یان لایببە، پاشان دووبارە کرتە لە Start بکە.
- یان تر بدە Apache. کرتە لە Config ← Apache (httpd.conf) بکە، ئەو دوو دێڕەی خوارەوە بگۆڕە، فایلەکە پاشەکەوت بکە و دووبارە Apache دەست پێبکە. لەمەودوا لە هەموو ناونیشانێکدا بنووسە، بۆ نموونە
http://localhost:8080/.
# Before: Listen 80
# ServerName localhost:80
Listen 8080
ServerName localhost:8080Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 3
Listenis the port Apache waits on.Listenئەو کە Apache چاوەڕێی لەسەر دەکات.- Lineدێڕی 4
ServerNameshould use the same port.ServerNameدەبێت هەمان بەکاربهێنێت.
- MySQL does not start and port 3306 is in use: another MySQL or MariaDB is already installed. Stop it in Services, or change the port in
my.ini(Config → my.ini). - The browser says "This site can't be reached" or "connection refused": Apache is not running, or the port in the address is wrong.
- When you finish working, click Stop for each module, then Quit.
- MySQL دەست پێناکات و 3306 بەکارهاتووە: MySQL یان MariaDBـیەکی تر پێشتر دامەزراوە. لە Services ڕایبگرە، یان لە
my.iniبگۆڕە (Config ← my.ini). - دەڵێت «This site can't be reached» یان «connection refused»: Apache کار ناکات، یان لە ناونیشانەکەدا هەڵەیە.
- کاتێک کارەکەت تەواو بوو، بۆ هەر مۆدیوڵێک کرتە لە Stop بکە، پاشان Quit.
Checking the server: localhost and htdocsپشکنینی ڕاژەکار: localhost و htdocs
The lecture's slide "Checking web server" has only two lines: http://localhost and "C drive → xampp → htdocs". Here is what they mean.
سلایدی «Checking web server» لە وانەکەدا تەنها دوو دێڕی تێدایە: http://localhost و «C drive ← xampp → htdocs». واتاکەیان ئەمەیە:
Checking the server: localhost and htdocsپشکنینی ڕاژەکار: localhost و htdocs
Open localhost in the browserlocalhost لە تۆڕگەڕدا بکەرەوە
With Apache running, type http://localhost in the browser's address bar. If you see the XAMPP dashboard ("Welcome to XAMPP"), your web server works. is a special name that always means this computer; its is 127.0.0.1. The request never leaves your computer, so it works even without the Internet.
لە کاتێکدا Apache کار دەکات، http://localhost لە بنووسە. ئەگەر داشبۆردی XAMPP («Welcome to XAMPP») ببینیت، کار دەکات. ناوێکی تایبەتە کە هەمیشە واتە ئەم کۆمپیوتەرە؛ 127.0.0.1ـە. هەرگیز کۆمپیوتەرەکەت جێناهێڵێت، بۆیە بەبێ کار دەکات.
Checking the server: localhost and htdocsپشکنینی ڕاژەکار: localhost و htdocs
Put your files in htdocsفایلەکانت بخە ناو htdocs
Apache only shows files that are inside one folder and its sub-folders. This folder is called the document root. In XAMPP on Windows it is the folder: C:\xampp\htdocs (C drive → xampp → htdocs). The path of a file inside htdocs becomes the path in the :
Apache تەنها ئەو فایلانە پیشان دەدات کە لەناو یەک و لاوەکییەکانیدان. بە ئینگلیزی بەم دەوترێت document root. لە XAMPPـی ویندۆزدا ئەمە : C:\xampp\htdocs (C drive ← xampp → htdocs). فایلێک لەناو htdocs دەبێتە ناو :
| File on the diskفایل لەسەر دیسک | Address in the browserناونیشان لە |
|---|---|
C:\xampp\htdocs\test.php | http://localhost/test.php |
C:\xampp\htdocs\shop\about.html | http://localhost/shop/about.html |
C:\xampp\htdocs\shop\index.php | http://localhost/shop/ (Apache opens index.php by itself)http://localhost/shop/ (Apache خۆی index.php دەکاتەوە) |
C:\Users\Aram\Desktop\test.php | No address: the file is outside htdocs, so Apache cannot show it.هیچ ناونیشانێکی نییە: فایلەکە لە دەرەوەی htdocsـە، بۆیە Apache ناتوانێت پیشانی بدات. |
/Applications/MAMP/htdocs/PhpProject2/index.php | http://localhost:8888/PhpProject2/index.php (MAMP on a Mac)http://localhost:8888/PhpProject2/index.php (MAMP لەسەر ماک) |
Think of a shop in the bazaar. The shopkeeper only sells what is on the shelves in the shop. Things in the storeroom at home cannot be sold, even if they belong to the same shopkeeper. htdocs is Apache's shop shelf: a file in your Desktop or Documents folder is "at home", and Apache cannot give it to a browser.
بیر لە دوکانێک لە بازاڕدا بکەرەوە. دوکاندارەکە تەنها ئەوە دەفرۆشێت کە لەسەر ڕەفەکانی دوکانەکەیە. ئەو شتانەی لە کۆگای ماڵەوەن ناتوانرێت بفرۆشرێن، هەرچەندە هی هەمان دوکاندارن. ڕەفی دوکانەکەی Apacheـە: فایلێک لە Desktop یان Documents «لە ماڵەوەیە» و Apache ناتوانێت بیداتە .
Where the analogy stops workingسنووری ئەم نموونەیە
A shop shelf is small, but htdocs can hold as many folders and files as you like. Each sub-folder becomes part of the URL.
ڕەفی دوکان بچووکە، بەڵام htdocs دەتوانێت هەر چەند و فایلێک بتەوێت لەخۆ بگرێت. هەر لاوەکی دەبێتە بەشێک لە .
Checking the server: localhost and htdocsپشکنینی ڕاژەکار: localhost و htdocs
Your first test pageیەکەم لاپەڕەی تاقیکردنەوەت
Create a new file C:\xampp\htdocs\test.php with any text editor and type this code. Then open http://localhost/test.php.
بە هەر فایلێکی نوێ بە ناوی C:\xampp\htdocs\test.php دروست بکە و ئەم کۆدە بنووسە. پاشان http://localhost/test.php بکەرەوە.
<?php
echo "<h1>It works!</h1>\n";
echo "<p>PHP version: " . PHP_VERSION . "</p>\n";It works! PHP version: 8.5.10
HTML sent to the browserئەو HTMLـەی دەنێردرێت بۆ تۆڕگەڕ
<h1>It works!</h1>
<p>PHP version: 8.5.10</p>The browser receives only HTML; the PHP code stays on the server. Your version number will be different (it depends on your XAMPP).
تەنها HTML وەردەگرێت؛ کۆدی PHP لەسەر دەمێنێتەوە. ژمارەی وەشانەکەی تۆ جیاواز دەبێت (بەپێی XAMPPـەکەت).
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 2
echosends text (here, an HTML heading) to the browser. You learn it properly in Output with echo and print.echoدەق (لێرەدا سەردێڕێکی HTML) بۆ دەنێرێت. لە دەرخستە بە echo و print بە تەواوی فێری دەبیت.- Lineدێڕی 3
PHP_VERSIONholds the version of the PHP that runs the page. The dot.joins texts together.PHP_VERSIONوەشانی ئەو PHPـە هەڵدەگرێت کە لاپەڕەکە کارپێدەکات. خاڵی.دەقەکان پێکەوە دەلکێنێت.
The phpinfo() testتاقیکردنەوەی phpinfo()
phpinfo() is a of PHP. It prints a long page of information about PHP: its version, its configuration and its extensions. It is a great way to see that PHP is running and how it is set up. Every PHP developer does this quick and easy test on a new machine.
phpinfo() PHPـە. پەڕەیەکی درێژ لە زانیاری دەربارەی PHP چاپ دەکات: وەشانەکەی، و . ڕێگایەکی زۆر باشە بۆ ئەوەی ببینیت PHP کار دەکات و چۆن ڕێکخراوە. هەموو گەشەپێدەرێکی PHP ئەم تاقیکردنەوە خێرا و ئاسانە لەسەر کۆمپیوتەرێکی نوێ دەکات.
<?php phpinfo(); ?>phpinfo() PHP Version => 8.5.10 System => ... Build Date => ... ... Server API => Command Line Interface ... Loaded Configuration File => (none) ...
This is the start of the real output when PHP 8.5 runs the file in a command window ("..." marks lines left out). In the browser, through XAMPP, you see the same information as a long, coloured table, and "Server API" says Apache 2.0 Handler.
ئەمە سەرەتای ڕاستەقینەیە کاتێک PHP 8.5 فایلەکە لە پەنجەرەی فەرماندا کارپێدەکات («...» نیشانەی دێڕە لابراوەکانە). لە ، لە ڕێگەی XAMPPـەوە، هەمان زانیاری وەک درێژ و ڕەنگاوڕەنگ دەبینیت و «Server API» دەڵێت Apache 2.0 Handler.
Things to look for on the page:
ئەو شتانەی لە پەڕەکەدا سەیریان بکە:
- PHP Version at the top: the PHP that runs your pages.
- Server API: Apache 2.0 Handler means PHP runs inside Apache.
- Loaded Configuration File: the file that holds PHP's settings, for example
C:\xampp\php\php.ini. - Sections such as mysqli, pdo_mysql and pdo_sqlite: the database extensions you will need later.
- PHP Version لە سەرەوە: ئەو PHPـەی لاپەڕەکانت کارپێدەکات.
- Server API: Apache 2.0 Handler واتە PHP لەناو Apacheـدا کار دەکات.
- Loaded Configuration File: فایلی کە PHP هەڵدەگرێت، بۆ نموونە
C:\xampp\php\php.ini. - بەشەکانی وەک mysqli، pdo_mysql و pdo_sqlite: ئەو پاشکۆیانەی کە دواتر پێویستت دەبن.
Lab 1: a PHP project in NetBeansتاقیگەی ١: پڕۆژەیەکی PHP لە NetBeans
The goal of Lab 1 is to set up a new PHP project and write your first PHP code. The lab uses the NetBeans IDE.
ئامانجی تاقیگەی یەکەم ئەوەیە کە پڕۆژەیەکی نوێی PHP ڕێکبخەیت و یەکەم کۆدی PHP بنووسیت. تاقیگەکە NetBeans بەکاردەهێنێت.
In Kurdish: set up XAMPP with NetBeans and run a first Hello World PHP page, the same steps as Lab 1.
بە کوردی: لەگەڵ NetBeans ئامادە دەکات و یەکەم ، واتە Hello World، دەخاتە کار؛ هەمان هەنگاوەکانی تاقیگەی یەکەم.
Kurdish: XAMPP + NetBeans first PHP project (Hello World)
بە کوردی: یەکەم پرۆژەی بە و NetBeans (Hello World).
Lab 1: a PHP project in NetBeansتاقیگەی ١: پڕۆژەیەکی PHP لە NetBeans
Editors and IDEsدەستکاریکەر و ژینگەی کۆکراوەی گەشەپێدان
PHP scripts are just text files. They do not belong to any special program, so you can write them with any or IDE you like. An (Integrated Development Environment) is a rich program for developing software. It joins a programming editor with many helpful tools.
PHP تەنها فایلی دەقن. هی هیچ بەرنامەیەکی تایبەت نین، بۆیە دەتوانیت بە هەر یان کە حەزی لێدەکەیت بیاننووسیت. بەرنامەیەکی دەوڵەمەندە بۆ پەرەپێدانی نەرمەکاڵا. دەستکاریکەرێکی لەگەڵ زۆر ئامرازی بەسوود کۆدەکاتەوە.
- Colours and auto-complete: the editor colours your code and suggests names while you type.
- : finding and removing errors. (The Kurdish word in the course notes literally means "killing the bugs".) The IDE marks many mistakes before you run the page.
- Projects: it keeps all files of one website together in one project.
- Run button: it opens your page in the browser through the web server.
- ڕەنگ و تەواوکردنی خۆکار: دەستکاریکەرەکە کۆدەکەت ڕەنگ دەکات و لە کاتی نووسیندا ناو پێشنیار دەکات.
- : دۆزینەوە و لابردنی . زۆرێک لە پێش کارپێکردنی لاپەڕەکە نیشان دەکات.
- پڕۆژەکان: هەموو فایلەکانی یەک لە یەک پڕۆژەدا پێکەوە دەهێڵێتەوە.
- دوگمەی Run: لاپەڕەکەت لە ڕێگەی لە دەکاتەوە.
Popular choices: Apache NetBeans (used in the lab, free), Visual Studio Code (free), PhpStorm (paid, free for students) and Notepad++ (a simple free editor for Windows). The steps below use NetBeans.
هەڵبژاردە باوەکان: Apache NetBeans (لە تاقیگەدا بەکارهاتووە، بێبەرانبەرە)، Visual Studio Code (بێبەرانبەر)، PhpStorm (بە پارەیە، بۆ خوێندکاران بێبەرانبەرە) و Notepad++ (دەستکاریکەرێکی سادە و بێبەرانبەری ویندۆز). هەنگاوەکانی خوارەوە NetBeans بەکاردەهێنن.
Lab 1: a PHP project in NetBeansتاقیگەی ١: پڕۆژەیەکی PHP لە NetBeans
Creating the project step by stepدروستکردنی پڕۆژەکە هەنگاو بە هەنگاو
The lab screenshots were made on a Mac with MAMP, while the lecture installs XAMPP on Windows. Do not let this confuse you: the steps are the same, only the folder and the port are different. Use the column that matches your computer.
وێنەکانی تاقیگەکە لەسەر ماک لەگەڵ MAMP گیراون، لە کاتێکدا وانەکە XAMPP لەسەر ویندۆز دادەمەزرێنێت. با ئەمە تووشی تێکچوونت نەکات: هەنگاوەکان هەمان شتن، تەنها و جیاوازن. ئەو ستوونە بەکاربهێنە کە لەگەڵ کۆمپیوتەرەکەت دەگونجێت.
| Setting | XAMPP on WindowsXAMPP لەسەر ویندۆز | MAMP on a Mac (lab screenshots)MAMP لەسەر ماک (وێنەکانی تاقیگە) |
|---|---|---|
| Web folder (document root) وێب (document root) | C:\xampp\htdocs | /Applications/MAMP/htdocs |
| Sources Folder (PhpProject2) | C:\xampp\htdocs\PhpProject2 | /Applications/MAMP/htdocs/PhpProject2 |
| Apache port (default) Apache (بنەڕەتی) | 80 | 8888 |
| Project URL | http://localhost/PhpProject2/ | http://localhost:8888/PhpProject2/ |
| New Project shortcutکورتەڕێی New Project | Ctrl+Shift+N | Shift+Cmd+N (⇧⌘N) |
- Start the server firstسەرەتا ڕاژەکار دەست پێبکە
Start Apache (and MySQL) in the XAMPP Control Panel. NetBeans does not start the web server for you.
Apache (و MySQL) لە XAMPP دەست پێبکە. NetBeans بۆت دەست پێناکات.
- Open NetBeansNetBeans بکەرەوە
Open NetBeans and wait until its Start Page appears.
NetBeans بکەرەوە و چاوەڕێ بکە تا Start Pageـەکەی دەردەکەوێت.
- New projectپڕۆژەی نوێ
Choose File → New Project… (
Ctrl+Shift+Non Windows, ⇧⌘N on a Mac). A list of project types appears.File ← New Project… هەڵبژێرە (
Ctrl+Shift+Nلە ویندۆز، ⇧⌘N لە ماک). لیستی جۆرەکانی پڕۆژە دەردەکەوێت. - Choose Projectهەنگاوی Choose Project
In Choose Project, select the category PHP and the project PHP Application, then click Next. (PHP Application with Existing Sources is for a folder that already has PHP files, and PHP Application from Remote Server is for a website on another computer.)
لە Choose Project، پۆلی PHP و پڕۆژەی PHP Application هەڵبژێرە، پاشان کرتە لە Next بکە. (PHP Application with Existing Sources بۆ کە پێشتر فایلی PHPـی تێدایە و PHP Application from Remote Server بۆ لەسەر کۆمپیوتەرێکی تر.)
Choose PHP → PHP Application. ("PHP 5" in the description is old text from NetBeans 8.1; new versions create PHP 8 projects.)PHP ← PHP Application هەڵبژێرە. («PHP 5» لە ڕوونکردنەوەکەدا دەقێکی کۆنی NetBeans 8.1ـە؛ وەشانە نوێیەکان پڕۆژەی PHP 8 دروست دەکەن.)Course material - Name and Locationهەنگاوی Name and Location
In Name and Location: (1) type the Project Name; the Sources Folder must be inside your web folder, for example
C:\xampp\htdocs\PhpProject2. (2) PHP Version: choose the newest PHP 8 in the list. As the dialog says, it is used only for hints. (3) Default Encoding: keep UTF-8. (4) Leave "Put NetBeans metadata into a separate directory" unticked and click Next.لە Name and Location: (١) Project Name بنووسە؛ Sources Folder دەبێت لەناو وێبەکەتدا بێت، بۆ نموونە
C:\xampp\htdocs\PhpProject2. (٢) PHP Version: نوێترین PHP 8 لە لیستەکەدا هەڵبژێرە. وەک پەنجەرەکە دەڵێت، تەنها بۆ یارمەتیدانی دەستکاریکەرەکە بەکاردێت. (٣) Default Encoding: UTF-8 بهێڵەوە. (٤) «Put NetBeans metadata into a separate directory» بێ نیشان بهێڵەوە و کرتە لە Next بکە.Name and Location in the lab (MAMP on a Mac). With XAMPP the Sources Folder is C:xampphtdocsPhpProject2. The lab's PHP 5.6 is out of date: pick PHP 8.Name and Location لە تاقیگەدا (MAMP لەسەر ماک). لەگەڵ XAMPP، Sources Folder دەبێتە C:xampphtdocsPhpProject2. PHP 5.6ـی تاقیگەکە کۆنە: PHP 8 هەڵبژێرە.Course material - Run Configurationهەنگاوی Run Configuration
In Run Configuration: (1) Run As: keep Local Web Site (running on local web server). (2) Project URL is the address that opens the project in the browser. Its port must match your Apache:
http://localhost/PhpProject2/for XAMPP,http://localhost:8888/PhpProject2/for MAMP. (3) Leave Copy files from Sources Folder to another location unticked (see the note below). (4) Click Next. As the dialog says, you can change these settings later in Project Properties.لە Run Configuration: (١) Run As: Local Web Site (running on local web server) بهێڵەوە. (٢) Project URL ئەو ناونیشانەیە کە پڕۆژەکە لە دەکاتەوە. دەبێت وەک Apacheـەکەت بێت:
http://localhost/PhpProject2/بۆ XAMPP،http://localhost:8888/PhpProject2/بۆ MAMP. (٣) Copy files from Sources Folder to another location بێ نیشان بهێڵەوە (تێبینییەکەی خوارەوە ببینە). (٤) کرتە لە Next بکە. وەک پەنجەرەکە دەڵێت، دواتر دەتوانیت ئەم لە Project Properties بگۆڕیت.Run Configuration in the lab. The Project URL uses MAMP's port 8888; with XAMPP on port 80 it is http://localhost/PhpProject2/.Run Configuration لە تاقیگەدا. Project URL 8888ـی MAMP بەکاردەهێنێت؛ لەگەڵ XAMPP لەسەر 80، دەبێتە http://localhost/PhpProject2/.Course material - PHP Frameworks and FinishPHP Frameworks و Finish
In PHP Frameworks, do not tick anything. Frameworks such as Symfony, Nette or Zend are ready-made code structures for big projects; this course does not use them. Click Finish. (You may also click Next to see step 5, Composer, and then Finish.)
لە PHP Frameworks، هیچ شتێک نیشان مەکە. وەک Symfony، Nette یان Zend پێکهاتەی ئامادەی کۆدن بۆ پڕۆژە گەورەکان؛ ئەم کۆرسە بەکاریان ناهێنێت. کرتە لە Finish بکە. (دەتوانیت کرتە لە Nextیش بکەیت بۆ بینینی هەنگاوی ٥، Composer، پاشان Finish.)
Lab 1: a PHP project in NetBeansتاقیگەی ١: پڕۆژەیەکی PHP لە NetBeans
Your new project and the Run buttonپڕۆژە نوێیەکەت و دوگمەی Run
NetBeans creates the project and opens index.php. On the left, the Projects panel shows your project folder: everything you add will appear inside this folder. On the right is the editor, where you write your PHP code, embedded in HTML.
NetBeans پڕۆژەکە دروست دەکات و index.php دەکاتەوە. لە لای چەپ، پانێڵی Projects پڕۆژەکەت پیشان دەدات: هەر شتێک زیاد بکەیت لەناو ئەم دەردەکەوێت. لە لای ڕاست دەستکاریکەرەکەیە، ئەو شوێنەی کۆدی PHPـی تێدا دەنووسیت، کە لەناو HTMLـدا دادەکوترێت.
index.phpـی بنەڕەتی لە لای ڕاست. (پڕۆژەکانی خوێندکارانی تر لە وێنەکە لابراون.)Course material<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
// put your code here
?>
</body>
</html>HTML sent to the browserئەو HTMLـەی دەنێردرێت بۆ تۆڕگەڕ
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>The PHP block printed nothing, so the browser shows an empty page. PHP also removes the line break right after ?>, which is why </body> moved up.
بلۆکی PHP هیچی چاپ نەکرد، بۆیە لاپەڕەیەکی بەتاڵ پیشان دەدات. PHP هەروەها هێڵی نوێی دوای ?> لادەبات، بۆیە </body> هاتووەتە سەرەوە.
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 1
An HTML5 page. You review HTML in the next chapter.
لاپەڕەیەکی HTML5. لە بەشی داهاتوودا پێداچوونەوە بە HTMLـدا دەکەیت.
- Lineدێڕی 2-6
An HTML . You may delete it.
HTMLـە. دەتوانیت بیسڕیتەوە.
- Lineدێڕی 9
UTF-8, so Kurdish text shows correctly.
UTF-8، بۆ ئەوەی دەقی کوردی بە دروستی پیشان بدرێت.
- Lineدێڕی 13-15
A PHP block inside the HTML body. Your PHP code goes between
<?phpand?>.بلۆکێکی PHP لەناو bodyـی HTMLـدا. کۆدی PHPـەکەت لە نێوان
<?phpو?>دا دەنووسرێت.
To run the page, click the green Run Project button in the toolbar (or press F6). NetBeans opens the Project URL in your browser. If the browser cannot connect, check that Apache is running and that the port in the Project URL is right.
بۆ کارپێکردنی لاپەڕەکە، کرتە لە دوگمە سەوزەکەی Run Project بکە لە شریتی ئامرازەکاندا (یان F6 دابگرە). NetBeans Project URL لە دەکاتەوە. ئەگەر نەیتوانی پەیوەندی بکات، بپشکنە کە Apache کار دەکات و لە Project URLـدا دروستە.
Lab 1: a PHP project in NetBeansتاقیگەی ١: پڕۆژەیەکی PHP لە NetBeans
Common setup mistakesکێشە باوەکان و چارەسەریان
| What you seeئەوەی دەیبینیت | Whyهۆکار | Fixچارەسەر |
|---|---|---|
| "This site can't be reached" / "connection refused"پەیامی «This site can't be reached» یان «connection refused» | Apache is not running, or the port in the address is wrong.Apache کار ناکات، یان لە ناونیشانەکەدا هەڵەیە. | Start Apache. Make the port in the Project URL match Apache's port.Apache دەست پێبکە. Project URL وەک Apache لێبکە. |
| "Not Found" (error 404)پەیامی «Not Found» ( 404) | The project folder is not inside htdocs, or the folder name in the address is wrong. پڕۆژەکە لەناو htdocs نییە، یان ناوی لە ناونیشانەکەدا هەڵەیە. | Create the project inside htdocs, or use the copy option.پڕۆژەکە لەناو htdocs دروست بکە، یان هەڵبژاردەی کۆپیکردن بەکاربهێنە. |
| You see PHP code instead of the resultلەبری دەرئەنجامەکە کۆدی PHP دەبینیت | The page was opened with file://, or the file ends in .html.لاپەڕەکە بە file:// کراوەتەوە، یان فایلەکە بە .html کۆتایی دێت. | Open it through http://localhost/... and save it as .php.لە ڕێگەی http://localhost/...ـەوە بیکەرەوە و وەک .php پاشەکەوتی بکە. |
Kurdish letters look like الپیتە کوردییەکان وەک ال دەردەکەون | The file is not saved as UTF-8, or <meta charset="UTF-8"> is missing.فایلەکە وەک UTF-8 پاشەکەوت نەکراوە، یان <meta charset="UTF-8"> نییە. | Keep UTF-8 as the encoding and keep the meta line.UTF-8 وەک بهێڵەوە و دێڕی meta بهێڵەوە. |
Exercisesڕاهێنانەکان
Install XAMPP. Start Apache and MySQL, and open localhost in your browser. Write down the port numbers you see in the Control Panel.
دابمەزرێنە. Apache و MySQL دەست پێبکە و localhost لە بکەرەوە. ژمارەی ئەو بنووسە کە لە دەیانبینیت.
Hintئاماژە
Follow the installation steps, then click Start twice in the Control Panel.
هەنگاوەکانی دامەزراندن بەکاربهێنە، پاشان دوو جار لە کرتە لە Start بکە.
Show answerوەڵامەکە پیشان بدە
- After clicking Start, Apache and MySQL turn green and their buttons change to Stop.
- Apache shows ports 80, 443; MySQL shows port 3306.
http://localhostopens the XAMPP dashboard ("Welcome to XAMPP"). If it does not, read the Apache log and check whether port 80 is used by another program.
- دوای کرتەکردن لە Start، Apache و MySQL سەوز دەبن و دوگمەکانیان دەبنە Stop.
- Apache 80، 443 پیشان دەدات؛ MySQL 3306.
http://localhostداشبۆردی XAMPP دەکاتەوە («Welcome to XAMPP»). ئەگەر نەیکردەوە، لۆگی Apache بخوێنەوە و بپشکنە ئایا تر 80ـی بەکارهێناوە.
Set up a new PHP project in NetBeans called PhpProject2, so that it runs on your local web server. Write down the Sources Folder and the Project URL you used.
پڕۆژەیەکی نوێی PHP لە NetBeans بە ناوی PhpProject2 ڕێکبخە، بەشێوەیەک لەسەر ناوخۆییەکەت کار بکات. ئەو Sources Folder و Project URLـەی بەکارتهێنا بنووسە.
Hintئاماژە
File → New Project → PHP → PHP Application. The folder must be inside htdocs, and the port must match Apache.
File → New Project → PHP ← PHP Application. دەبێت لەناو htdocs بێت و دەبێت وەک Apache بێت.
Show answerوەڵامەکە پیشان بدە
| Setting | XAMPP (Windows)XAMPP (ویندۆز) | MAMP (Mac)MAMP (ماک) |
|---|---|---|
| Project Name | PhpProject2 | PhpProject2 |
| Sources Folder | C:\xampp\htdocs\PhpProject2 | /Applications/MAMP/htdocs/PhpProject2 |
| PHP Version | newest PHP 8نوێترین PHP 8 | newest PHP 8نوێترین PHP 8 |
| Default Encoding | UTF-8 | UTF-8 |
| Run As | Local Web Site | Local Web Site |
| Project URL | http://localhost/PhpProject2/ | http://localhost:8888/PhpProject2/ |
| Copy files… | untickedبێ نیشان | untickedبێ نیشان |
| PHP Frameworks | none, then Finishهیچ، پاشان Finish | none, then Finishهیچ، پاشان Finish |
Find out your PHP specification: write the phpinfo() function inside your PHP file (index.php of your project), then run the file with the Run button. Which PHP version do you have, and which php.ini file is loaded?
تایبەتمەندییەکانی PHPـەکەت بدۆزەوە: phpinfo() لەناو فایلی PHPـەکەتدا بنووسە (index.phpـی پڕۆژەکەت)، پاشان بە دوگمەی Run فایلەکە کارپێبکە. وەشانی PHPـەکەت چەندە و کام فایلی بارکراوە؟
Show answerوەڵامەکە پیشان بدە
<?php
phpinfo();
?>The browser shows the long PHP information page. Read PHP Version at the top and Loaded Configuration File (with XAMPP: C:\xampp\php\php.ini). Remove the call (or delete the file) when you have finished.
پەڕە درێژەکەی زانیاریی PHP پیشان دەدات. PHP Version لە سەرەوە و Loaded Configuration File بخوێنەوە (لەگەڵ XAMPP: C:\xampp\php\php.ini). کاتێک تەواو بوویت بانگکردنەکە لابەرە (یان فایلەکە بسڕەوە).
Write the browser address for each file. Apache (XAMPP) uses port 80.
ناونیشانی بۆ هەر فایلێک بنووسە. Apache (XAMPP) 80 بەکاردەهێنێت.
C:\xampp\htdocs\index2.phpC:\xampp\htdocs\school\students.phpC:\xampp\htdocs\school(the folder containsindex.php)D:\homework\task.php
C:\xampp\htdocs\index2.phpC:\xampp\htdocs\school\students.phpC:\xampp\htdocs\school(index.phpـی تێدایە)D:\homework\task.php
Show answerوەڵامەکە پیشان بدە
http://localhost/index2.phphttp://localhost/school/students.phphttp://localhost/school/(Apache opensindex.phpby itself)- No address: the file is outside htdocs. Move it into htdocs first.
http://localhost/index2.phphttp://localhost/school/students.phphttp://localhost/school/(Apache خۆیindex.phpدەکاتەوە)- هیچ ناونیشانێکی نییە: فایلەکە لە دەرەوەی htdocsـە. سەرەتا بیگوازەرەوە بۆ ناو htdocs.
Apache will not start because Microsoft IIS already uses port 80. You change httpd.conf to Listen 8081. (a) Which address now opens C:\xampp\htdocs\PhpProject2\index.php? (b) What must the Project URL in NetBeans be?
Apache دەست پێناکات چونکە مایکرۆسۆفت پێشتر 80ـی بەکارهێناوە. httpd.conf دەگۆڕیت بۆ Listen 8081. (أ) ئێستا کام ناونیشان C:\xampp\htdocs\PhpProject2\index.php دەکاتەوە؟ (ب) Project URL لە NetBeans دەبێت چی بێت؟
Show answerوەڵامەکە پیشان بدە
(a) http://localhost:8081/PhpProject2/index.php (or http://localhost:8081/PhpProject2/). (b) http://localhost:8081/PhpProject2/. The port in every address must match the port Apache listens on; also change ServerName to localhost:8081.
(أ) http://localhost:8081/PhpProject2/index.php (یان http://localhost:8081/PhpProject2/). (ب) http://localhost:8081/PhpProject2/. لە هەموو ناونیشانێکدا دەبێت وەک ئەو بێت کە Apache گوێی لێ دەگرێت؛ هەروەها ServerName بگۆڕە بۆ localhost:8081.
Summary and reviewکورتە و پێداچوونەوە
- PHP needs a web server. XAMPP turns your computer into one for testing.
- XAMPP = X (cross-platform) + Apache + MariaDB/MySQL + PHP + Perl. WAMP (Windows) and MAMP (Mac) are similar packages.
- Start Apache and MySQL in the Control Panel. Default ports: 80 and 443 (Apache), 3306 (MySQL).
- Put your files in
C:\xampp\htdocsand open them withhttp://localhost/..., never by double-clicking. - The port in the URL must match the server's port (80 for XAMPP, 8888 for MAMP, 81 on the lab computers).
phpinfo()proves PHP is running; delete the test file afterwards.- In NetBeans: File → New Project → PHP Application, Sources Folder inside htdocs, UTF-8, the right Project URL, no framework, Finish, Run.
- PHP پێویستی بە هەیە. کۆمپیوتەرەکەت بۆ تاقیکردنەوە دەکاتە .
- XAMPP = X () + Apache + MariaDB/MySQL + PHP + Perl. WAMP (ویندۆز) و MAMP (ماک) پاکێجی هاوشێوەن.
- Apache و MySQL لە دەست پێبکە. بنەڕەتی: 80 و 443 (Apache)، 3306 (MySQL).
- فایلەکانت بخە ناو
C:\xampp\htdocsو بەhttp://localhost/...بیانکەرەوە، هەرگیز بە دوو کرتە. - لە دەبێت وەک بێت (80 بۆ XAMPP، 8888 بۆ MAMP، 81 لەسەر کۆمپیوتەرەکانی تاقیگە).
phpinfo()دەیسەلمێنێت PHP کار دەکات؛ دواتر فایلی تاقیکردنەوەکە بسڕەوە.- لە NetBeans: File ← New Project ← PHP Application، Sources Folder لەناو htdocs، UTF-8، Project URLـی دروست، بێ ، Finish، Run.
Why can't you open a PHP page by double-clicking it?بۆچی ناتوانیت لاپەڕەیەکی PHP بە دوو کرتە بکەیتەوە؟
Because then the file does not go through a web server. Only a server with PHP can run the code; the browser alone just shows the text.
چونکە ئەو کاتە فایلەکە بە ناو تێناپەڕێت. تەنها کە PHPـی هەبێت دەتوانێت کۆدەکە جێبەجێ بکات؛ بە تەنها دەقەکە پیشان دەدات.
What are WAMP and XAMPP?WAMP و XAMPP چین؟
All-in-one packages that install a web server (Apache), a database (MySQL/MariaDB) and PHP together. WAMP is for Windows only; XAMPP is cross-platform.
پاکێجی هەمووی-لە-یەکن کە (Apache)، (MySQL/MariaDB) و PHP پێکەوە دادەمەزرێنن. WAMP تەنها بۆ ویندۆزە؛ XAMPP .
What is htdocs?htdocs چییە؟
XAMPP's document root, C:\xampp\htdocs: the folder whose files Apache can show in the browser.
document rootـی XAMPPـە، C:\xampp\htdocs: ئەو کە Apache دەتوانێت فایلەکانی لە پیشان بدات.
Which ports does XAMPP use by default, and for what?XAMPP بە شێوەی بنەڕەتی کام پۆرتانە بەکاردەهێنێت و بۆ چی؟
80 for HTTP and 443 for HTTPS (both Apache), and 3306 for the MySQL/MariaDB database.
80 بۆ HTTP و 443 بۆ HTTPS (هەردووکیان Apache) و 3306 بۆ MySQL/MariaDB.
Apache will not start. What do you check first?Apache دەست پێناکات. سەرەتا چی دەپشکنیت؟
The log in the Control Panel. Usually another program uses port 80 or 443. Use Netstat to find it, stop it, or change Apache's Listen port in httpd.conf.
تۆمارەکەی . زۆرجار بەرنامەیەکی تر 80 یان 443 بەکاردەهێنێت. بە Netstat بیدۆزەوە، ڕایبگرە، یان Listenـی Apache لە httpd.conf بگۆڕە.
What does the "PHP Version" setting in NetBeans change?هەڵبژاردەی «PHP Version» لە NetBeans چی دەگۆڕێت؟
Only the editor's hints and syntax checks. The PHP that actually runs your pages is the one installed in XAMPP.
تەنها پێشنیارەکان و پشکنینی دەستکاریکەرەکە. ئەو PHPـەی بە ڕاستی لاپەڕەکانت کارپێدەکات هی ناو XAMPPـە.
Videoڤیدیۆ
Watch a videoسەیری ڤیدیۆیەک بکە
A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.
Why PHP needs a local server, then install XAMPP, start Apache and MySQL, and make a project folder in htdocs.
بۆچی پێویستی بە ناوخۆیی هەیە، پاشان ، هەڵکردنی و و دروستکردنی پرۆژە لەناو .
Watch 0:00–5:58: why a local server, install XAMPP, start Apache, htdocs
لە 0:00 تا 5:58 سەیر بکە: بۆچی ناوخۆیی پێویستە، ، هەڵکردنی و .
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
HTML Basics: Documents, Links and Tablesبنەماکانی HTML: بەڵگەنامە، بەستەرەکان و خشتەکان
Related lecturesوانە پەیوەندیدارەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Apache Friends: XAMPP download and documentation
- Apache Friends: XAMPP for Windows FAQ
- PHP Manual: phpinfo()
- PHP Manual: Built-in web server
- Apache HTTP Server: DocumentRoot directive
- Apache HTTP Server: Binding to addresses and ports (Listen)
- The Apache Software Foundation
- MariaDB Foundation
- Apache NetBeans
- MAMP
- WampServer
- Wikipedia: LAMP (software bundle)
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.