# Help for the PHP Newbies

**URL:** <https://forum.getkirby.com/t/help-for-the-php-newbies/965>\
**Category:** Questions\
**Tags:** v2\
**Created:** [May 1, 2015, 6:32pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965 "2015-05-01T18:32:02Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![cirstenkot](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/cirstenkot/32/1591_2.png) [@cirstenkot](https://forum.getkirby.com/u/cirstenkot)\
**Post date:** [May 1, 2015, 6:32pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/1 "2015-05-01T18:32:02Z")

</div>

Hi!

I am new to PHP and started to use Kirby a few months ago. But when I read (well let’s say just taking a look ;)) at the cheatsheet I feel kinda stupid. For example [user create](http://getkirby.com/docs/cheatsheet/users/create) . How can I get my head around this and start coding. Is it the best way just to learn PHP from scratch? Or just trying to understand the way Kirby uses PHP?

Thanks for your time to answer this!

---

<div class="post-metadata">

**Author:** ![Luke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/luke/32/3083_2.png) [@Luke](https://forum.getkirby.com/u/Luke)\
**Post date:** [May 1, 2015, 6:56pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/2 "2015-05-01T18:56:27Z")

</div>

If you’re looking to code PHP professionally, it may be be worth investing in some training, or certification. I have been doing web development on and off as a hobby for about 15 years. But when I decided a few years ago to make a go at it as a profession I took some certificate courses at O’Reilly School of Technology, to enhance my resume mostly. Their courses eased into each lesson nicely and I would fathom it was very beginner friendly and their instructors we always helpful on the few occasions I got stuck on a problem or assignment, or just wanted to question the methods they used in lieu of other similar methods to achieve specific tasks and why they took that route.

In lieu of that, there are many helpful tutorials and lessons. The vast majority of my knowledge has come from analyzing other people’s code (plugins and such) or reading tutorials. This is just a more scattered approach rather than finding the necessary beginner training from a single source. But rest assured, if you need to know _nearly_ anything, Google already has your answer for free. 🙂

On a side note, that’s an interesting piece of code you’ve chosen to analyze. I’ve never seen try{} used. A quick Google turned up [this stack overflow question](http://stackoverflow.com/questions/17549584/how-to-efficiently-use-try-catch-blocks-in-php) though. Learn something new every day on these forums. Well, almost.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 1, 2015, 8:07pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/3 "2015-05-01T20:07:20Z")

</div>

Hello again, as Luke, I’ve been into PHP development for quite a while and always trying to learn something new, mainly by trying to solve a problem with the help of Google and Stackoverflow, by reading and trying to understand other people’s code and by just trying things out.

Let’s just do that with the `$user-\>create() example:

In a test environment, do the following:

1. Create a new folder `/user-create` in `/content`.
2. Put a text file in it called user-create.txt
3. Create a new template called user-create.php and put in the code from the example
4. Open your browser at yourlocalhostaddress/yourprojectfolder/user-create
5. See what happens …
6. You should now have a new account folder in `/site/accounts` called john

Of course, that in itself doesn’t make too much sense, it just creates one user and if you open the page a second time, you get an error message, because you can’t create the user a second time. So you’d have to combine this bit of code with a form that collects the data and then passes it into the array of the user create method … but one step at a time 😉

If you don’t want to get too complicated for starters, then you don’t need that much PHP knowledge, because the methods Kirby comes with make many things a whole lot easier than with vanilla PHP, just like using jQuery instead of vanilla JS.

A good starting point, I think, is to try out the different methods and see what they do really …

---

<div class="post-metadata">

**Author:** ![cirstenkot](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/cirstenkot/32/1591_2.png) [@cirstenkot](https://forum.getkirby.com/u/cirstenkot)\
**Post date:** [May 2, 2015, 8:48am UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/4 "2015-05-02T08:48:06Z")

</div>

Thank you alot again! I will give it a try. I am following a course @Lynda, reading the missing PHP manual and always give Google a try. But I think I am missing the basics using the code like provided in the example. I just can’t connect/combine the things I learned into using the code like above. But then again I have to slow down a little and just begin with your example and take step 2 when I am done with one 😉

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 2, 2015, 9:32am UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/5 "2015-05-02T09:32:00Z")

</div>

You’re welcome 😄, the thing is, if you do a basic PHP course, you learn all the basics first. And in basic PHP, there is no `$user->create()`, of course. That is a Kirby method of the $user class which is defined in the `user.php` like this:

(This is just to demonstrate a bit how this stuff is all connected, pls. don’t get scared away … 😳)

```php
static public function create($data = array()) {

    // sanitize the given data for the new user
    $data = static::sanitize($data, 'insert');

    // validate the dataset
    static::validate($data, 'insert');

    // create the file root
    $file = kirby::instance()->roots()->accounts() . DS . $data['username'] . '.php';

    // check for an existing username
    if(file_exists($file)) {
      throw new Exception('The username is taken');
    }

    // create a new hash for the password
    if(!empty($data['password'])) {
      $data['password'] = password::hash($data['password']);
    }

    static::save($file, $data);

    // return the created user project
    return new static($data['username']);

  }

```

This function, in turn, uses a lot of other functions, which are defined elsewhere in the Kirby core, e.g. a static function called “sanitize”.

If you then look at the static sanitize function just above the user create function,you will find this bit of code:

```php
static public function sanitize($data, $mode = 'insert') {

    // all usernames must be lowercase
    $data['username'] = str::slug(a::get($data, 'username'));

    // return the cleaned up data
    return $data;

  }

```

Again, there are other functions used here: `str::slug` and `a::get`which are defined in the Kirby toolkit. The str-thingy is a string manipulation function, and a::get for working with arrays.

Now, if you are still with me on this expedition, you can go visit the Kirby toolkit `/kirby/toolkit/lib`, where you will find the array methods in `a.php` and the string methods in `str.php`. And that’s where we finally find more basic PHP … 😆

---

<div class="post-metadata">

**Author:** ![cirstenkot](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/cirstenkot/32/1591_2.png) [@cirstenkot](https://forum.getkirby.com/u/cirstenkot)\
**Post date:** [May 2, 2015, 9:52am UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/6 "2015-05-02T09:52:21Z")

</div>

I am with you! 😉 This is helping me alot! It is like a free fall but I like it.

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [April 24, 2018, 10:54am UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/8 "2018-04-24T10:54:33Z")

</div>

If anyones reading this in the future, and they happen to have LinkedIn Premium, don’t forget that includes LinkedIn Learning, which is really everything from [Lynda.com](http://Lynda.com). (LinkedIn own [Lynda.com](http://Lynda.com) these days.) Plenty of PHP training in there.

You can also get somewhere for free with [CodeAcademy](https://www.codecademy.com/en/tracks/php) and I can recommend [Team Treehouse](https://teamtreehouse.com).

[StackSocial](https://stacksocial.com/collections/online-courses/development) also often have great deals on video & eBooks for learning Development.

---

<div class="post-metadata">

**Author:** ![cirstenkot](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/cirstenkot/32/1591_2.png) [@cirstenkot](https://forum.getkirby.com/u/cirstenkot)\
**Post date:** [April 25, 2018, 2:32pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/9 "2018-04-25T14:32:12Z")

</div>

Tnx!!! Very helpful!

---

<div class="post-metadata">

**Author:** ![11bits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/11bits/32/860_2.png) [@11bits](https://forum.getkirby.com/u/11bits)\
**Post date:** [April 25, 2018, 5:09pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/10 "2018-04-25T17:09:51Z")

</div>

I have basic knowledge of PHP, and for me the best reference is the [Kirby documentation](https://getkirby.com/docs).

I encourage the **Kirby team** to create more articles and tutorials, as far as possible. Video tutorials would be great.

---

<div class="post-metadata">

**Author:** ![manuelmoreale](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/manuelmoreale/32/839_2.png) [@manuelmoreale](https://forum.getkirby.com/u/manuelmoreale)\
**Post date:** [April 26, 2018, 6:10am UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/11 "2018-04-26T06:10:09Z")

</div>

Also as a reference, for anyone learning PHP:

- [PHP The Right Way](http://www.phptherightway.com/) is a nice reference site
- Laracasts has an [entire series](https://laracasts.com/skills/php) about PHP

---

<div class="post-metadata">

**Author:** ![mikestott89](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mikestott89/32/10476_2.png) [@mikestott89](https://forum.getkirby.com/u/mikestott89)\
**Post date:** [August 29, 2021, 5:25pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/12 "2021-08-29T17:25:18Z")

</div>

Hi,

I’m new to Kirby and have been using JQuery with WordPress.

I have seen multiple comments here advising to use Vanilla JS over JQuery, I’ve been to Vanilla JS’s website and even searched YouTube and Google for installation tips, I’ve also been searching the Kirby forum but I don’t seem to get some straight forwards information on how to set it up, please can you point me towards a guide or tutorial? Thank you in advance!

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [August 29, 2021, 5:33pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/13 "2021-08-29T17:33:26Z")

</div>

If you want to use vanilla JS, there is nothing particular to set up, you can include your script with the js helper to make your life easier: [js() | Kirby CMS](https://getkirby.com/docs/reference/templates/helpers/js)

If you want to stick with Jquery, you can also include it with this helper. The helper accept the path to the script as argument, e.g

```auto
<?= js('assets/js/myscript.js') ?>

```

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [August 29, 2021, 5:34pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/14 "2021-08-29T17:34:59Z")

</div>

Vanilla JS usually just refers to using plain JavaScript rather than a bulky framework. What is confusing is there is a framework called Vanilla JS, which could use (although I’m not familiar with it personally). [http://vanilla-js.com/](http://vanilla-js.com/)

I would recommend using ordinary JavaScript were possible. If you need a little more power / easier life, I would suggest something like the DOMtastic which will give you a jquery like way to target things but with nowhere near the over head. [https://domtastic.js.org/](https://domtastic.js.org/)

An excellent place to learn vanilla js is the MDN Web docs who have a complete course for free as well as complete reference (like a dictionary) for JavaScript (and CSS and HTML too).

> **[JavaScript basics - Learn web development | MDN](https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics)**
>
> JavaScript is a programming language that adds interactivity to your website. This happens in games, in the behavior of responses when buttons are pressed or with data entry on forms; with dynamic styling; with animation, etc. This article helps you...

I would also recommend the videos by Net Ninja. These are excellent, concise courses on everything web, all for free. [https://www.youtube.com/c/TheNetNinja/playlists](https://www.youtube.com/c/TheNetNinja/playlists)

Be sure to check out the Modern Javascript course [Modern JavaScript Tutorial #1 - Intro & Setup - YouTube](https://www.youtube.com/watch?v=iWOYAxlnaww&list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc)

---

<div class="post-metadata">

**Author:** ![mikestott89](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mikestott89/32/10476_2.png) [@mikestott89](https://forum.getkirby.com/u/mikestott89)\
**Post date:** [August 29, 2021, 9:00pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/15 "2021-08-29T21:00:11Z")

</div>

Super helpful! Some good reading and watching for me to do, I really appreciate it. And yes, it seems the framework is what was confusing me.

---

<div class="post-metadata">

**Author:** ![sebastiangreger](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sebastiangreger/32/16176_2.png) [@sebastiangreger](https://forum.getkirby.com/u/sebastiangreger)\
**Post date:** [August 30, 2021, 6:04am UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/16 "2021-08-30T06:04:54Z")

</div>

Another good reference source for many standard tasks (and beyond) is [https://plainjs.com/javascript/](https://plainjs.com/javascript/); they also have a registry of jQuery-free tools/plugins.

…and this site has some handy sample code for replicating core jQuery functionalities in plain JS: [http://youmightnotneedjquery.com/](http://youmightnotneedjquery.com/)

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 31, 2021, 4:45am UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/17 "2021-08-31T04:45:33Z")

</div>

> [@jimbobrjames](#):
>
> What is confusing is there is a framework called Vanilla JS, which could use (although I’m not familiar with it personally). [http://vanilla-js.com/](http://vanilla-js.com/)

That “framework” is a literal joke. If you download it, you get an empty file. All the code examples are plain JS as supported by the browsers. So it‘s just a site that advocates for building sites without JS frameworks. 😅

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [August 31, 2021, 7:56am UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/18 "2021-08-31T07:56:05Z")

</div>

> [@lukasbestle](#):
>
> That “framework” is a literal joke. If you download it, you get an empty file.

Yes i thought initially it was broken, then i looked more closely at the code 🙂

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:22pm UTC](https://forum.getkirby.com/t/help-for-the-php-newbies/965/19 "2025-02-06T17:22:56Z")

</div>


