Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting started with MyBB 1.9 development - Composer
#1
In MyBB 1.9, we're introducing Composer to help us manage third party libraries and autoload classes. In the past, we copied third party dependencies into the inc/3rdparty folder. This made managing library updates difficult.

What is Composer?

Composer is a tool to manage dependencies in PHP projects. It allows us to define a list of packages that MyBB depends on and then manages installing and updating those dependencies automatically.

Installing the Composer command line tool on your system

To start working with Composer and installing/updating packages, you need to install the Composer tool on your system. You can either install Composer in a path local to a copy of the MyBB repository that you're working on, or you can install it globally. In this post, we'll be installing it locally as it's useful to have a single copy that you can use across multiple projects.

The download and install process is fully documented on the Composer website. The easiest way is to run the commands from the top of that page, which we haven't copied below as the file hash of the Composer package changes with every new version release they make.

Installing the MyBB dependencies

Now that you've installed Composer on your system, you can install the libraries that MyBB 1.9 depends on using it. Dependencies are installed in the composer.json file found in the root of the MyBB directory. At the time of writing, we depend upon the following libraries:
  • PHP version 7.0 or newer
  • Laravel's container package (illuminate/container)
  • Laravel's events package (illuminate/events)
  • Laravel's routing package (lluminate/routing)
  • Twig (twig/twig)

To install all of these dependencies, run the following command from the MyBB root:

php composer.phar install --no-suggest --optimize-autoloader

This will create the directory inc/vendor and fill it with several files and folders including inc/vendor/autoload.php and inc/vendor/twig/.

The version that is installed will be the same for all developers working on MyBB 1.9 thanks to the composer.lock file which specifies exact versions of packages to use.

Adding a new dependency

The easiest way to add a new dependency is to do so via the command line. First of all, find the name of the dependency on Packagist. For the purpose of this post, I've chosen to install the Laravel translation package illuminate/translation. You can easily install the dependency by running the command found below the package title on the Packagist page. For example:

composer require illuminate/translation

This will add the dependency to the composer.json file and actually download the package itself into the inc/vendor folder for you. The library will be available via the autoloader (inc/vendor/autoload.php) and available to use straight away with no further effort.


This page is also available on the MyBB GitHub Wiki, and can be found here
Reply
#2
FYI, I like this as a way of going forward with 1.9x.
Reply
#3
Get ready for immense support threads as we are adapting new technologies, its going to be much harder for newbies to maintain their forums.
[Image: logo.svg.svg]
Reply
#4
I'm on website only hosting. Already on PHP7, but no shell to speak of. Can I work around this by executing the commands via a cron job in CPanel...

Will it work?

Or should I move to a VPS in order to use 1.9?
Reply
#5
(03-14-2018, 05:29 AM)snakeoilos Wrote: I'm on website only hosting. Already on PHP7, but no shell to speak of. Can I work around this by executing the commands via a cron job in CPanel...

Will it work?

Or should I move to a VPS in order to use 1.9?

No, it's likely we'll deploy a pre-compiled version along with the raw one; the install process won't differ much, if nothing at all, from the one you are used to.
[Image: fSGNVQj.png]
Reply
#6
(03-14-2018, 04:02 AM)effone Wrote: Get ready for immense support threads as we are adapting new technologies, its going to be much harder for newbies to maintain their forums.

That's simply not true. We'll offer a ZIP package as we do now with everything in it ready to go. The install and upgrade process will be exactly the same as it is now.
Reply
#7
This is a nice update Euan Smile
I do feel that there should be two ways of adding dependencies i.e. a pre compiled version and a version which anyone can fork/use to change 3rd party packages based on requirements.
Reply
#8
Lightbulb 
Today Can Install MyBB 1.9 Development
In General you must have basic knowledge of composer and ssh to can install a development copy of mybb 1.9

Installation summary
1. download and install composer to you server
2. download the MyBB 1.9 branch Github
3. Do the installation steps of MyBB.
4. in terminal SSH you must run: composer install
5. MyBB 1.9 Develompent Test OnLine Now can see the forums, Example Thread OnLine

Note: for that installation you must have performace you server! for example:
1. PHP version 7.0 or newer
2. Install composer on you server
3. allow_url_fopen must be enabled in php.ini.  That its important becuase when composer start to install MyBB dependencies the allow_url_fopen must be enabled

[Image: cpanel22.png]


Video MyBB 1.9 development install
:



Personal Notes:
for many people maybe the SSH and the Composer and the edit .ini setting to be enabled the allow_url_fopen must be a problem. 
well, it's just my opinion!

Question About Composer:
1. When install mybb 1.9, it was Not enabled the allow_url_fope.
2. setting the correct to enable to allow_url_fope via MultiPHP INI Editor
3. Try to Install Again the MyBB 1.9 via Composer install but display error of composer.lock, not remember the message, its like: 
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them

4. try composer update but cannot, maybe bacuase the composer check that it is already installed... and ¿how can update that files? for example:
Quote:Package operations: 59 installs, 0 updates, 0 removals
- Installing symfony/polyfill-mbstring (v1.7.0): Downloading (failed)
- Installing nesbot/carbon (1.25.0): Cloning cbcf13da0b from cache
- Installing psr/simple-cache (1.0.1): Downloading (failed)
- Installing illuminate/contracts (v5.6.12): Cloning 00a8296c63 from cache
- Installing doctrine/inflector (v1.3.0): Downloading (failed)  
- ... etc


Resume of my Terminal
Quote:[[email protected]]$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file  
- Installing doctrine/inflector (v1.3.0): Cloning 5527a48b73 from cache
- Installing illuminate/container (v5.6.12): Cloning 4a42d667a0 from cache
- Installing illuminate/events (v5.6.12): Cloning b6e73ed404 from cache
- Installing symfony/routing (v4.0.6): Cloning 9c6268c197 from cache
- Installing symfony/http-foundation (v4.0.6): Cloning 6c181e81a3 from cache
- Installing illuminate/session (v5.6.12): Cloning 90bb5857fb from cache
- Installing illuminate/routing (v5.6.12): Cloning 716d1a29ef from cache
- Installing twig/twig (v2.4.7): Downloading (failed)  
- Installing squizlabs/php_codesniffer (3.2.3):
Cloning 4842476c43 from cache
symfony/translation suggests installing symfony/config ()
illuminate/filesystem suggests installing league/flysystem (Required to use the Flysystem local and FTP drivers (~1.0).)
illuminate/filesystem suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (~1.0).)
illuminate/filesystem suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
illuminate/filesystem suggests installing league/flysystem-sftp (Required to use the Flysystem SFTP driver (~1.0).)
illuminate/session suggests installing illuminate/console....
Reply
#9
Thanks. You can also run composer install in your local machine and then upload the generated files to your server afterwards. This should drop the allow_url_fopen requirement.
[Image: fSGNVQj.png]
Reply
#10
(06-18-2018, 08:46 AM)Shade Wrote: Thanks. You can also run composer install in your local machine and then upload the generated files to your server afterwards. This should drop the allow_url_fopen requirement.

Shade you Are welcome!

But think... i am testing on a live server... ¿you want to run all he code again via composer on my localhost machine and export all files to my server?

I do not thinks thats is efficent.... for what is comPoser? Its a tools for my server... 

Your comments its for me it's lost time...  because i am used the correct tools for testing.

Sorry... and thanks for your comments

Note: how to fix via composer? Or update via composer ?

Comments are welcome...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)