Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,127 members, 7,811,177 topics. Date: Sunday, 28 April 2024 at 05:22 AM

Let's Talk About Composer (PHP) - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Let's Talk About Composer (PHP) (600 Views)

Let's Talk About OpenAI ChatGPT. What's The Future of Developers ? / Backend Software Engineers, Let's Talk About System Design / Who Knows How To Edit A Wordpress Website And Work With Visual Composer (2) (3) (4)

(1) (Reply) (Go Down)

Let's Talk About Composer (PHP) by Karleb(m): 9:07pm On Mar 07, 2021
If you don't know, composer is a PHP dependency manager. It is the PHP version of NPM (Node Package Manager).

Dependencies simply means the code your code rely on. That is, if my `post` object uses a `category` I wrote or someone else wrote, the category object is the product class' dependency.

If you've been following PHP for some years, you'd know before PHP 7 PEAR was quite popular. PHP Extension and Application Repository (PEAR) had to take the back seat upon the introduction of Composer.

Composer was introduced in 2015 and it is the de facto way of managing and using dependencies.

One sweet thing about Composer is the namespace and autoload. Gone are the days of `require`, `require_once`, and it's cousins `include` and `include_once`. You can literally write your code, give it a namespace you fancy and use the namespace anywhere in so far the folder is a part of the the autoloaded folder. This is actually very simple in terms of code.

I'm not saying include and require is bad but when you include or require, you are basically importing the whole file into the one it is needed.

What if there variables with similar names in both (could be more than two) file for example?
This would lead to an error, a quite unnecessary error if you ask me.

With composer, the files are only required in one place, the `index.php` file. That's all, it actually works like magic because the code have been written by excellent PHP developers to make your life better. cheesy

1 Like

Re: Let's Talk About Composer (PHP) by Karleb(m): 9:52pm On Mar 08, 2021
I see that anti spam bot does not want me post anything here.
Re: Let's Talk About Composer (PHP) by tensazangetsu20(m): 10:28am On Mar 09, 2021
You can actually use composer for wordpress theme/plugin development now with bedrock.
Re: Let's Talk About Composer (PHP) by Karleb(m): 11:17am On Mar 09, 2021
tensazangetsu20:
You can actually use composer for wordpress theme/plugin development now with bedrock.

I don't know about bedrock but you can use composer with WordPress without any extra package. The only reason why composer usage is not common within WordPress community is because WordPress itself doesn't encourage its usage with its funny styles and conventions.

It only takes someone who has used composer/OOP outside of WordPress to understand its importance in wordpress.
Re: Let's Talk About Composer (PHP) by tensazangetsu20(m): 11:28am On Mar 09, 2021
Karleb:


I don't know about bedrock but you can use composer with WordPress without any extra package. The only reason why composer usage is not common within WordPress community is because WordPress itself doesn't encourage its usage with its funny styles and conventions.

It only takes someone who has used composer/OOP outside of WordPress to understand its importance in wordpress.

True but WordPress is changing especially with the introduction of the Rest API in 2017 and then the introduction of Gutenberg which uses React. Magento has also done the same thing. A lot of WordPress devs are still stuck on the old ways sha but there are newer, more exciting ways of doing things in WordPress now especially at an enterprise level.
Re: Let's Talk About Composer (PHP) by qtguru(m): 11:28am On Mar 09, 2021
Karleb:


I don't know about bedrock but you can use composer with WordPress without any extra package. The only reason why composer usage is not common within WordPress community is because WordPress itself doesn't encourage its usage with its funny styles and conventions.

It only takes someone who has used composer/OOP outside of WordPress to understand its importance in wordpress.

Composer relies on Autoload and some PSR compliant packages, WordPress doesn't adhere much to it, so it's the reason Composer is odd for WP, but WP existed way before Composer and the FIG and PSR Movement came. But WordPress has been changing tensazangetsu20 explained some new things I never knew about it.

But I just looked at Bedrock and this is quite new
Re: Let's Talk About Composer (PHP) by Karleb(m): 11:45am On Mar 09, 2021
qtguru:


Composer relies on Autoload and some PSR compliant packages, WordPress doesn't adhere much to it, so it's the reason Composer is odd for WP, but WP existed way before Composer and the FIG and PSR Movement came. But WordPress has been changing tensazangetsu20 explained some new things I never knew about it.

But I just looked at Bedrock and this is quite new

That is not an excuse. Laravel had to be re-written by Taylor Otwell and went on to become the best PHP framework. I personally love its poetic nature.

WordPress developers themselves want it to be written properly. I learnt about timber and twig some months ago. But the developers at the helm of affairs are just so contempt with their pockets.

If only wordpress could be re-written with OOP, it will take over more than 50 per cent of the internet.

1 Like 1 Share

Re: Let's Talk About Composer (PHP) by tensazangetsu20(m): 11:47am On Mar 09, 2021
Karleb:


That is not an excuse. Laravel had to be re-written by Taylor Otwell and went on to become the best PHP framework. I personally love its poetic nature.

WordPress developers themselves want it to be written properly. I learnt about timber and twig some months ago. But the developers at the helm of affairs are just so contempt with their pockets.

If only wordpress could be re-written with OOP, it will take over more than 50 per cent of the internet.
True sha, It is already at 40 percent. I think they are doing this. The CEO of WordPress was at that gatsby conference and he talked about a whole lot of changes coming to the WordPress codebase. That is something they might be working on.
Re: Let's Talk About Composer (PHP) by qtguru(m): 12:02pm On Mar 09, 2021
Karleb:


That is not an excuse. Laravel had to be re-written by Taylor Otwell and went on to become the best PHP framework. I personally love its poetic nature.

WordPress developers themselves want it to be written properly. I learnt about timber and twig some months ago. But the developers at the helm of affairs are just so contempt with their pockets.

If only wordpress could be re-written with OOP, it will take over more than 50 per cent of the internet.

I love Twig, I use it in Processwire, that is a good point as a Software Developer, but as a business they will lose existing partners like WP_Tarvern and almost all plugins won't be backward compatible overnight. WordPress makes too much money that there is no business value to do that.

Awon Team Laravel , never tried it, the Static code threw me off, but they have nice tools though
Re: Let's Talk About Composer (PHP) by tensazangetsu20(m): 12:10pm On Mar 09, 2021
qtguru:


I love Twig, I use it in Processwire, that is a good point as a Software Developer, but as a business they will lose existing partners like WP_Tarvern and almost all plugins won't be backward compatible overnight. WordPress makes too much money that there is no business value to do that.

Awon Team Laravel , never tried it, the Static code threw me off, but they have nice tools though
They might already have it but its not open source. https://wpvip.com/. This is also WordPress but it's not free and only for enterprise. This is where they make a bulk of their revenue from.
Re: Let's Talk About Composer (PHP) by Karleb(m): 1:59pm On Mar 09, 2021
qtguru:


Awon Team Laravel , never tried it, the Static code threw me off, but they have nice tools though

I don't really know what you mean by static code but if you are referring to static object methods then I'd say Laravel doesn't use any.

It has a library called Facades, which is quite different from the Facade design pattern.

It makes you write a normal object method like a static method. Which means you can write:

Product::where('category_id', 20)->paginate(5);

Product::paginate(5);

If you are taking about something else, then it is fine. cheesy
Re: Let's Talk About Composer (PHP) by qtguru(m): 2:04pm On Mar 09, 2021
Karleb:


I don't really know what you mean by static code but if you are referring to static object methods then I'd say Laravel doesn't use any.

It has a library called Facades, which is quite different from the Facade design pattern.

It makes you write a normal object method like a static method. Which means you can write:

Product::where('category_id', 20)->paginate(5);

Product::paginate(5);

If you are taking about something else, then it is fine. cheesy

This is my problem, if I see that I will assume it is a static method call. Instead a magic call to an instance. Laravel is good but not for me , Symfony is what I prefer and used to use, haven't written PHP in a while except Moodle
Re: Let's Talk About Composer (PHP) by Karlebolu(m): 5:12pm On Mar 09, 2021
I no know wetin I do this anti spam bot o! angry
Re: Let's Talk About Composer (PHP) by qtguru(m): 7:54pm On Mar 09, 2021
Karlebolu:
I no know wetin I do this anti spam bot o! angry


It does like thT
Re: Let's Talk About Composer (PHP) by Karleb(m): 5:32pm On Mar 10, 2021
Because of anti spam bot that keeps banning me, I've decided to create a hashnode blog.


https://karleb.hashnode.dev

I will be putting contents there from time to time.

(1) (Reply)

Differences Between Computer Science And Engineering?? / Please Guys Help Me Criticize My New Forum Site Design / I Wrote My Most Difficult C++ Programme Yet,barely 2 weeks since I started(pics)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 33
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.