Thanks for the hard work, Sir. Followed and Liked. Can't wait for more tutorial videos rolling out
Videos on how to extend Flarum
clarkwinkelmann I set a reminder
Thanks to everyone who joined in! The stream can be replayed above.
clarkwinkelmann Thanks for the awesome live stream ** navigating to the github repo now **
- Edited
@clarkwinkelmann, do you know of a good node.js / yarn (meow) video tutorial which starts at the very beginning? Something to help me learn why that yarn command (js compilation, I guess) is needed and what that is doing? Yeah, I need something that basic.
Edit: Ooo. I'm looking into how can I do all of this online on a simple Chromebook for example. So that I don't have to use my Mac desktop and be tied to that if I don't want to. I've come across codeenvy.io. You can set up a workspace and stack for free online. A tutorial on creating a Flarum Extension, but 100% online, not in a local offline environment, would be .
And another edit: After a pure fork of your poke demo and installing on my Flarum, I get:
Flarum encountered a boot error (Error)
Class 'ClarkWinkelmann\Poke\Extenders\ForumAttributes' not found
thrown in /vendor/zerosonesfun/poke/extend.php on line 24
But the class exists. I'm not seeing typos. I did see that in the extend file the forum/admin JavaScript was pointing to a dist folder which doesn't exist. I updated that.
010101 do you know of a good node.js / yarn video tutorial
Unfortunately no I don't have any tutorial to suggest. Yarn is just a package manager. The yarn commands actually call webpack which is yet another dependency used by Flarum.
010101 I'm looking into how can I do all of this online
This is not easy, because you need Composer. You might be able to work on a remote VPS from a Chromebook, but going completely in the cloud would require a Flarum-enabled online IDE.
010101 Class 'ClarkWinkelmann\Poke\Extenders\ForumAttributes' not found
I can't see anything wrong either no idea what's happening there...
clarkwinkelmann Alright, thanks! Yeah no matter how many times I read the extend docs I can’t wrap my head around the part where you do a yarn command. Docs say to just type:
npm install
npm run dev
Then I guess you’ll have your js file in the right place and format that it needs to be?
If I ever figure this stuff out I’m definitely writing a Flarum for dummies and non-devs like me book.
- Edited
npm install
means "install the packages defined in dependencies
in packages.json
". Those end up in node_modules
folder.
npm run dev
means "run the dev
script defined in packages.json
". Which maps to webpack --mode development --watch
, which launches webpack. Webpack automatically reads the webpack.config.js
file, which imports a default configuration for Flarum from the flarum-webpack-config
dependency.
clarkwinkelmann Cool. Ok. Every little bit I hear from you and others is helping. I guess when you do a yarn command in your tutorials you are doing something a little different. Or, just another way to do something.
I've discovered Google Cloud Shell and maybe I'm getting my hopes up, but with Google Cloud Shell, I might be able to get close or 100% to being able to develop Flarum extensions on my Chromebook.
- Edited
010101 Class 'ClarkWinkelmann\Poke\Extenders\ForumAttributes' not found
In vendor/composer/autoload_static.php
, find the array prefixDirsPsr4
, and add:
'ClarkWinkelmann\\Poke\\' => array ( 0 => __DIR__ . '/..' . '/clarkwinkelmann/flarum-ext-poke/src', ),
010101 I did see that in the extend file the forum/admin JavaScript was pointing to a dist folder which doesn't exist
Yes, I did encounter that issue too. So, I ended up moving admin.js and forum.js into a /dist
folder
So finally, have you installed the extension successfully?
As I said in the video, javascript dist files were not included in git due to the extension being a demo. So you have to run yarn install
and yarn build
(or dev
) before you can use it
- Edited
clarkwinkelmann Arhhh.. sorry for not taking full attention in the class
EDIT: Yassssss!!! I manage to install it on my Flarum finally
It works like a charm
- Edited
010101 I guess when you do a yarn command in your tutorials you are doing something a little different.
It has the same effect. npm
is the original package manager for Node.js that was born about 10 years ago. The company maintains the npmjs.com website, the npm public registry and the npm
terminal utility that is usually bundled with Node.js.
The npm history is quite bumpy, and there was a period where very little improvements were made to the npm
CLI. One of the main problems was that it was veeery slow to install packages (still faster than composer
though). It also had some other annoying bugs and weird behaviours.
So some alternatives were born, the most popular being yarn
by Facebook. yarn
still uses the npm public registry (it actually mirrors it on Facebook's servers) but provides a different terminal utility that does similar things, presumably better. It was a common opinion that it was true (and a fact wrt performance), at the time, but today npm
is much better than it was and has catched up on many aspects, so as far as I'm concerned there aren't many reasons to prefer yarn
over npm
today. I found npm
to be actually faster than yarn
in my limited testing.
In short, I would suggest to stick with npm
unless you have a real reason for not using it. There's a lot more documentation and resources about npm than yarn on the web.
matteocontrini Wow, thanks for the clarification, sir. I always confuse both of them (yarn and npm) and now I think I should just stick to npm?
jvloo I think I should just stick to npm?
I think it's easier unless you have particular needs or something to complain about npm
matteocontrini Thank you!
- Edited
Join me live in 3 hours at 21:00 CET / 18:00 UTC for this week's livestream.
We will create a birthday extension. I'll let you guess how the theme was chosen
- Edited
End of stream. Thanks to everyone who joined!
The code can be found here https://github.com/clarkwinkelmann/flarum-ext-birthday . Again, it's not published to Packagist because it's not a completely finished extension, but feel free to fork, rename and publish your own version of it!
The replay is available:
- Edited
Join me live in 2 hours at 20:30 CET / 18:40 UTC
We will be adding new features to the Linguist extension.