Blog

Archive for the ‘Development’ Category

An alternative approach to setting up a development environment on Windows

Posted by battye in Development, Extensions with the tags , on May 29th, 2017

In the last article I looked at setting up a simple development environment on Windows using WAMP. If you would like to review that, please visit https://blog.phpbb.com/2017/02/28/how-to-set-up-a-development-environment-on-windows/

The longer you spend developing software, the more seriously you start to take setting up the perfect development environment. And the more seriously you start to take following best practices. One of these practices is setting up a development environment that matches the production environment that you are using. There are a couple of reasons why this is beneficial. Firstly, if multiple developers are working on a project then you can be sure that code written by one person will work for the other developers. And secondly, when that code is deployed to a production environment you know that it should theoretically work straight away seeing it was written in a matching development environment.

A simple example of failing to do this would be if a developer was using a PHP7 development environment and wrote a statement which included the spaceship operator. If this code was then deployed on a PHP5 environment, the code would not work. If the developer, knowing that the production environment runs PHP5, had set up their development environment accordingly this bug would have been noticed much sooner.

At first impression, it seems impossible that a developer writing and testing code on their Windows PC can set up a local development environment that matches their live web server which in the vast majority of cases is running on Unix. But this is actually not the case, it is possible – and in fact, not all that difficult – to do this.

It can be done using a couple of Windows programs that enable the creation of virtual Unix machines. Basically what this means is that you can set up a lightweight Unix server that runs within Windows, so you can still use your favourite Windows text editors and tools but when it comes to running the code it will be run in Unix. In this article I’ll be looking at Vagrant and VirtualBox.

Note: This article assumes basic knowledge of the command line on Windows and Unix.

 

SETTING UP VAGRANT, VIRTUALBOX and PUTTY

The first step is to install VirtualBox, which Vagrant supports out of the box. VirtualBox is a program which allows for the management of virtual machines and can be downloaded from: https://www.virtualbox.org/wiki/Downloads

Use the default set up options.

Now Vagrant needs to be installed. Vagrant runs alongside VirtualBox to allow users to quickly provision new and different types of development environments. It can be downloaded from https://www.vagrantup.com/downloads.html and once again the default installation options should be used.

You can confirm that it’s correctly installed by rebooting your PC, and then opening Command Prompt (cmd.exe) and running the command “vagrant”. This should return example usage options.

Note: Version 1.94 of Vagrant seems to have a couple of bugs, which I encountered trying to install this on a Windows 7 machine (I know, I know! But it’s the only Windows PC I had access to). The first resulted in a number of error messages when running the “vagrant” command. This was resolved by running “vagrant plugin install vagrant-share –plugin-version 1.1.8”. The second bug resulted in errors when running “vagrant up”, which I resolved by replacing 3 files – the procedure is explained at
https://github.com/mitchellh/vagrant/issues/8520#issuecomment-297792410 – it appears this will be resolved in v1.95.

With Vagrant now installed, create a folder on your PC where you want your Vagrant projects. I called mine VagrantProjects. In your command prompt window, “cd” into this folder. Then run this command: “vagrant init”. This will create a Vagrantfile. This is a file where development environment settings are stored.

Now run “vagrant box add ubuntu/xenial64” – this will add an Ubuntu 16.04 virtual box, a new release of Ubuntu. It is worth bearing in mind that there are plenty of other boxes you can choose from. Some even have the LAMP stack pre-installed which if you want to save time could be a good option. You can view a list at https://atlas.hashicorp.com/boxes/search

The download may take some time on slower connections. When it’s complete, open Vagrantfile and modify this variable to have the listed value:

config.vm.box = “ubuntu/xenial64”

Note: these steps can be combined if you simply run “vagrant init ubuntu/xenial64”
Then run “vagrant up” while still in that directory.

Watch the messages in the command prompt window for the SSH username and password. You will need to note these down so when the virtual machine is running you can log into it.

Once the VM (virtual machine) has booted, you can open the VirtualBox application to confirm that it has indeed been created. If you run “vagrant status” you will see that the state is running.

Next, run “vagrant ssh” – on Windows it likely won’t work. But it will provide some important information. The host/port/username will be shown again but so will “private key” – this path is important.

An SSH client needs to be installed now. This is a client that allows you to log in to a remote server – but in this case it can be used to log in to the virtual machine. Putty is a very lightweight and effective client, and can be downloaded and installed from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html – download both Putty and PuttyGen.

Firstly, open PuttyGen, click load, and the choose the private key path specified a moment ago. Then using the default settings, click save private key. I called it pg_private_key.ppk. This key is later used merely to authenticate you and grant you access to the virtual machine.

Now open Putty. In the first screen fill out these details, which should match the information Vagrant displayed to you earlier:

Host name: 127.0.0.1
Port: 2222

Now go to Connections -> SSH -> Auth -> Private key file for authentication and select the ppk file.

Under Connections -> Data you can enter under “auto login username” the username shown in the command prompt earlier. Then go to Sessions, and under Saved Sessions type “Vagrant”. Click “Save”. Now you will not have to perform this step again, you can simply double click “Vagrant” in the future to quick-load your VM.

Finally click open, and a new command window will appear. But this time, it’s your new virtual server!

From the Putty window, type “logout” to leave the session. And in the Windows command prompt window type “vagrant halt” to shutdown the virtual machine. “vagrant status” will confirm that the state is powered off.

 

INSTALLING THE LAMP STACK

The “Linux” part has been handled now, but to continue setting up a local development environment Apache, MySQL and PHP is still required.

Firstly, Apache can be installed by running the following commands (once you have logged into the VM through Putty):

sudo apt-get -y update
sudo apt-get -y install apache2
sudo rm -rf /var/www/
sudo ln -fs /vagrant/ /var/www

So that development can take place in Windows, but run on the Linux virtual machine there needs to be some level of directory synchronisation. The final two commands create a symbolic link so you can store your files locally but also run on the webserver in the virtual machine.

On your local machine, inside the VagrantProjects folder create a new folder called html/ – this is important because of the way Apache is set up. In that folder, create a file called index.html and put this in it:

<html>
<body>
<h1>It works.</h1>
</body>
</html>

Note: A shortcut for this can be followed by creating a script like the one at https://www.vagrantup.com/intro/getting-started/provisioning.html

Now open Vagrantfile and add the following entry:

config.vm.network :forwarded_port, guest: 80, host: 4567

Now run “vagrant halt” followed up by “vagrant up” to restart the virtual machine.

Go to http://127.0.0.1:4567/index.html in your browser and you will see the file created above.

With Apache now running, let’s install MySQL:

sudo apt-get -y install mysql-server php7.0-mysql

When prompted, choose a password for the MySQL database.

You can test the connection from the command line (still using the Putty window, as it’s local to the virtual machine) by typing this command:

mysql -h 127.0.0.1 -u root -p

… and entering the password chosen above.

Pro tip: if you wanted to quickly run an SQL query, you can do it by typing the query after you’ve run the previous command. Type “CREATE DATABASE test;” to try it out. Enter “exit” to exit from the query window.

Now to install PHP7:

sudo apt-get -y install php libapache2-mod-php

phpBB requires the XML/DOM extension, so also run this:

sudo apt-get -y install php-xml

Now create a file called phpinfo.php in your html/ folder, and put this in it:

<?php
phpinfo();
?>

And then run http://127.0.0.1:4567/phpinfo.php and you will see that PHP is running correctly. As this demonstrates, any files or subdirectories you put in the /html directory become accessible through the web server.

By this point, you have everything you need to install phpBB and you can use the “test” database that was created in an earlier step.

 

INSTALLING PHPMYADMIN

To install phpMyAdmin – a fantastic tool for viewing database tables and running queries in a visually appealing way – do the following. Run:

sudo apt-get -y install phpmyadmin

Select apache2 by pressing enter, when prompted. Then select “yes” when shown the dbconfig-common prompt. Finally enter your MySQL password.

Now run the following database queries (on the command line, using the mysql command demonstrated in the previous section):

GRANT ALL ON test.* TO phpmyadmin@localhost IDENTIFIED BY ‘password’;
FLUSH PRIVILEGES;

This creates a database user called phpmyadmin (with a password of your choice, specified in the command above) with access to the test database created earlier.

Then run this command:

sudo vim /etc/apache2/apache2.conf

This will open the vim text editor. Press “i” to enter text edit mode. Then add the following line at the end of the file:

Include /etc/phpmyadmin/apache.conf

Press “Escape”, then “:wq” to save and exit the file.

With this done, you will now be able to log into phpMyAdmin by visiting this URL – http://127.0.0.1:4567/phpmyadmin/ – after logging in you can see the dashboard and view your tables and run queries.

With this complete, you now have a working development environment running on Linux with Apache, PHP and MySQL installed along with phpMyAdmin.

How to set up a development environment on Windows

Posted by battye in Development, Extensions with the tags , on February 28th, 2017

What you’ll need:

  • WAMP
  • QuickInstall
  • phpBB 3.2

As software developers the most important aspect of the development process is setting up a local development environment. The vast majority of web servers run on Linux systems, but most consumer operating systems use Windows. This doesn’t preclude Windows users from developing PHP applications though. There are a number of ways to do this, such as using an emulator like Vagrant to create a virtualised Linux environment or actually installing the Linux operating system on your computer. But the easiest approach is to simply install an application which will allow PHP, MySQL and Apache to run on a Windows machine and the application I most like for this is called WAMP.

WAMP is a free program which can be downloaded from http://www.wampserver.com/en/. Select your operating system type and click on the download link.

Once downloaded, open the installer and select your desired language (English or French are the only options at this time). From here, follow the prompts – the default options should be sufficient.

Once set up, navigate to the www directory that WAMP has created (usually C:\wamp\www). This is where the webserver files are served from. For the purposes of this tutorial I created a subdirectory in here called “demo”.

Firstly, download the latest version of the QuickInstall tool – QuickInstall is an invaluable tool for developers because it allows multiple boards to be created with pre-defined settings and later managed at just a few clicks. Why this is so important is if, for example, you are developing multiple extensions you can easily set up a different board – a vanilla, brand new board – to test and develop each one on individually.

Extract the QuickInstall zip file contents into the “demo” folder.

Now, download the latest phpBB version from https://www.phpbb.com/downloads/ – v3.2.0 at the time of writing. When you extract the contents from the zip file, copy the “phpBB” folder to your clipboard. Now, go to \www\demo\quickinstall-master\sources and paste the folder here. This will be the source board that QuickInstall will use to create a new forum.

Finally the “boards”, “cache” and “settings” directories in QuickInstall need to be writable by PHP. This is all that needs to be done to set up a basic congifiguration of QuickInstall. If you now navigate to http://localhost/demo/quickinstall-master/ in your browser the setup page will be displayed, automatically displaying the Profiles tab.

q_1

Under database settings, enter “root” as the user and leave the password blank (these are the default WAMP settings; if you used something different then it’s important that it’s reflected here). In a real world environment you would never want to have a blank database password, but as this is strictly a local set up that nobody else will be accessing it will not pose a security problem.

The rest of the settings can be left as-is. I would however recommend under the admin settings using an easily memorable username and password though, because you may be accessing this test board very regularly, and under the populate board settings checking the Yes option just so you have some test data to work with.

Once you Submit this form, the Boards tab will become visible.

q_2

You can modify some settings such as the board name if you wish (handy if, as mentioned above, you wanted to create a different board for each different extension you are developing) but the only field that needs to be explicitly defined is the database/directory name. In the past I have just used an incremental naming system (“test_board_1”, “test_board_2”, etc) so I will use test_board_1 for this example, but you can use any name you want.

Once you click Submit, the button will be hidden momentarily. This is okay – due to the test data being inserted into the database it might take a little time for the board to be created. It shouldn’t take more than about a minute, after which point you will be automatically redirected to your test board and logged in:

q_3

At this point the board has been created in www\demo\quickinstall-master\boards\test_board_1 and a database created called “qi_test_board_1”. A great feature of WAMP is that it comes with phpMyAdmin, a web-based tool for manipulating MySQL databases and running queries. This can be accessed at http://localhost/phpmyadmin and you will see the new database listed there:

q_4

By this point you have a fully functioning phpBB testing environment which you can modify as you desire. Most aspiring developers will already have a text editor of choice, but if you are new to extension development there are a number of tools you can start out with. Notepad++ (https://notepad-plus-plus.org/) is a simple but powerful text editor which has been on the scene for many years; and is free. It doesn’t have all the bells and whistles but it has syntax highlighting, auto-completion and a few other handy things which work well for PHP development. Another nice text editor which is a little more modern and feature-filled is Sublime (https://www.sublimetext.com). Technically it is a paid product, but you can download and use it for free if you can put up with periodic reminders to buy the program. Otherwise you can easily purchase a license on their site.

For more advanced developers a full-fledged IDE might be desirable and the best one I’ve used is PhpStorm. It’s the IDE of choice for a number of phpBB team members and has more features than you could possibly ever use; the highlights being powerful debugging capabilities, refactoring, testing facilities and version control integration (such as Git).

Now you can get started on your extension idea, or any other tweaks and modifications you wish to make to phpBB!

phpBB to ship with VigLink extension

Posted by Marc Alexander in Development, Extensions on December 9th, 2016

Beginning with phpBB 3.2 Release Candidate 2, the phpBB package will include a VigLink extension.

Currently, we rely solely on ads served throughout phpBB.com to fund the project’s expenses, namely: web hosting, legal expenses, software licenses, travel expenses for community events, etc. Our ad revenue has been steadily declining for a long time because the unobtrusive ads we’re willing to serve to visitors are less and less profitable. We have explored a variety of alternate funding options, such as utilizing more profitable advertising or accepting donations, however we feel that these solutions would either be ineffective or result in tangible undesirable effects.

We believe that this is the best solution to our current problem, namely that it provides a necessary revenue stream for the project while not negatively affecting the usability of the phpBB software.

The new extension allows phpBB users to support the phpBB project or alternatively elect to monetize their forums using a service called VigLink. If you enable the VigLink extension, whenever a user follows a link from your forum to any of VigLink’s partner websites and performs certain actions (such as making a purchase), a referral credit will be generated. To be clear, this will only affect existing links and should be entirely unnoticeable. It can also be entirely disabled, at your discretion.

After installation, it will be up to you to pick between disabling or enabling VigLink to help support phpBB or to use your own VigLink Convert account to earn money with your board. In order to accommodate this newly added feature, we improved the overall look of the “Send statistics” page in the Admin Control Panel and extended it to support extensions:

viglink_acp_example

Codename for phpBB’s next version

Posted by Marc Alexander in Development on November 5th, 2016

After two weeks of voting and a bit of back and forth between the four candidates, we now have a final winner for the codename of our next version:

Proteus

With Proteus we’ll be moving on from Saturn and continue our deep space journey to Neptune’s second largest moon (based on the name Proteus, the shape-changing sea god of Greek mythology).

We’ll be updating the release process page in the next few weeks to reflect this as well as to update current maintenance periods and target release timeframes.

Thanks to everyone for participating in this vote!

Vote For phpBB’s Next Codename

Posted by VSE in Development with the tags , , , , , on October 16th, 2016

At phpBB we love codenames as much as we love Bertie.

Previously we have travelled to Mars and Saturn to find the most prominent features to name our versions. Now it’s time to come up with another codename for the version of phpBB.

In line with having an open mind for new features, looks, and changes in phpBB’s next major version we’re also opening up the decision on the codename to the community.

The phpBB Team has already pre-selected four possibilities from a rather long list.

Now it’s time for you, the community, to have the final say:
[Vote] Codename of next phpBB version

The vote will end in two weeks on October 30th, 2016.

Happy voting!


 beer_bertie

phpBB not vulnerable to ImageMagick exploit

Posted by Marc Alexander in Development, Security, Support on May 5th, 2016

As some of you might have noticed, a security issue has recently been uncovered in ImageMagick, a widely used software suite for displaying and modifying images. You can read about the full details of the exploit on news outlets like Ars Technica (article on ImageMagick exploit) and the ImageMagick community forum.

It has come to our attention that admins are unsure whether this affects their phpBB installation and/or what they might have to do to secure their installation.
First and foremost let me make it clear that, based on the currently available information, phpBB is not vulnerable to the exploits.
phpBB already verifies the supplied image types and therefore already contains one of the described mitigations for the ImageMagick vulnerabilities.

phpBB supports using ImageMagick for creating thumbnails only. Other parts of phpBB, such as image or general attachment uploads, are not using ImageMagick at all. The described exploits rely on directly passing uploads to ImageMagick and/or passing “clear text” image formats such as SVG or MVG to it. phpBB itself does not support these image types for creating thumbnails and therefore will not pass them onto ImageMagick. Additionally, supported image types are checked for integrity before passing it onto ImageMagick for thumbnail creation. Passing malicious files as described and disguising them as other image types is therefore not possible.

We hope this will help with clearing up any confusion or uncertainty on this subject.

phpBB 3.2 Rhea is near – help us test it now!

Posted by naderman in Development with the tags , , on March 26th, 2016

On October 28th, 2014, we published phpBB 3.1 Ascraeus, the culmination of nearly 8 years of development since phpBB 3.0—an eternity when it comes to web development. We learned our lesson from trying to build a major feature release over a timespan that saw major changes in web technologies; while our roadmap had to change frequently, none of the progress was made available to you—our users. When we finally released phpBB 3.1, I announced that phpBB would from now on see feature releases on an annual basis.

It has now been one year and 6 months since I made this statement. Our most recent release has been phpBB 3.2 Rhea 3.2.0 Beta2, on March 7th 2016. So we missed our goal, but we’re well on the way to reaching a new stable feature release before summer this year. We’ve been making great progress with tweaking our workflows to more strictly adhere to the schedule in the future.

As the Development Team Leader, I updated you much too infrequently on development progress, partly due to having many other tasks to also focus on. Unless you follow our development forums at Area51, or our social media accounts on Facebook or Twitter, you are unlikely to have heard of our recent 3.2 Beta releases. As these responsibilities exceed what a single person can do well, Marc Alexander stepped up in February to take over the Development Team Lead position. From now on, I will be responsible for more frequently informing you of all developments regarding phpBB, as its new Product Manager.

We are looking forward to your feedback on the Beta releases and upcoming final release candidates of phpBB 3.2 Rhea.We cannot produce a stable final product without your testing and bug reporting. Download Beta packages from our archive at https://download.phpbb.com/pub/release/3.2/unstable/3.2.0-b2/. Please keep in mind that you should not run this version of phpBB on your live sites yet, and no support will be offered until the RC phase.

If you’d like to get involved with phpBB development to help us finish new features faster, check out the information available on Area51. And lastly, if you’d like to stay up to date on phpBB development progress, follow this blog!

phpBB Developer Documentation

Posted by nickvergessen in Development, Extensions with the tags , , , on July 5th, 2015

When the phpBB Team met in Prague last month for a short productivity meeting we achieved many things. We fixed bugs, worked on our bamboo infrastructure, reduced the size of the extension validation queue and worked on a new phpBB/Symfony Authentication bridge however one of the most significant things we did was start the base of our new developer documentation:
https://area51.phpbb.com/docs/dev/31x/

The plan with this documentation is to consolidate all core and extension development related information that is currently spread out on our wiki, Area51 (and a variety of other places) into one central location.

As a first step the “[HowTo] Convert a 3.0 modification into a 3.1 extension” tutorial was converted and is now available to view here.

Since then, we have ported over many many other Wiki pages and readmes to the new doc system including:

The documentation is written using rst and our documentation source can be found in the “development” folder of our pre-existing documentation repository: https://github.com/phpbb/documentation/

We will be continuing to move existing documentation over the coming months and if you are familiar with rst and git(hub) and want to help, please do feel free to send pull requests. Whether it is with porting existing documentation over, fixing typos or even writing brand new pieces of documentation, every contribution is appreciated.

Development Update: Notifications & Custom Profile Fields

Posted by naderman in Development with the tags on February 19th, 2014

After releasing Alpha3 last week, the development team is working on fixing outstanding bugs and getting ready for the first Beta release. As I mentioned in a previous blog post, we are now working on transitioning existing hard coded profile fields – such as occupation or location – to custom profile fields. The pull request converting location to a custom profile field also introduced a new option to display custom profile fields on the memberlist. As we are turning hard coded fields into custom profile fields, we are ensuring that all previous functionality can be achieved through configuration. At the same time these options can now be used for other custom profile fields you may wish to display.

Ascraeus Notifications Dropdown

Ascraeus Notifications Dropdown

As we fixed a bug regarding the display of avatars in notifications I want to use this opportunity to show you the new notifications functionality we built into phpBB Ascraeus 3.1. You may be familiar with the concept of a central location for notifications from Facebook or Google+. The idea is to provide users with a single location that will inform them about all the activity they are interested in. So far this includes notifications regarding posts, such as replies to bookmarked or subscribed topics or posts you have been quoted in, notifications regarding moderation of newly submitted posts waiting for approval and reported posts as well as notifications for new private messages and requests to join a group you lead. You can configure whether and how you would like to be notified for each of these notification types individually in the User Control Panel. The options are email, Jabber or the notification on the website. Extensions can easily add new notification types making the system very flexible.

Further we’re now testing phpBB automatically with the alpha releases of PHP 5.6 on Travis CI. A final version of PHP 5.6 is expected this summer.

phpBB 3.1 Alpha3 Preview Release

Posted by naderman in Development with the tags on February 10th, 2014

We’re happy to announce the immediate availability of the third preview release of the upcoming phpBB 3.1, codenamed Ascraeus.

This preview release is targeted at phpBB developers and advanced users who wish to assist us with this very important testing phase. We do not recommend, and will not support, running this version in a live production environment.

As with previous releases we compiled a list of feature and bugfix highlights on our wiki. We now have a generic framework for dropdowns in prosilver. We’ve started to use it for the new topic tools button from where you can manage bookmarking, attachment downloads and subscriptions to topics. Topic titles now link directly to the oldest unread post.

The only known issue remains that updating from 3.0 to 3.1 on Microsoft SQL Server is not possible.

Please use this release for testing purposes only. As always, we will provide no support for upgrading until the RC stage and urge users not to use testing releases in a production site. Please help us by reporting any bugs you find via a ticket on our tracker.

Unstable packages are available on Area51 at area51.phpbb.com/downloads/. Information on moving from 3.0 to 3.1 (currently only for testing purposes) is available at wiki.phpbb.com/PhpBB3.1#Moving_from_3.0_to_3.1

Please note that phpBB 3.1 has some requirements that differ from phpBB 3.0:

PHP version 5.3.3 or greater
PHP’s json extension
Only PostgreSQL versions 8.3 and above are supported