Sie sind auf Seite 1von 5

COMP10120 Lab Session 8

Web development: Getting it all


together a group website
Contents
8.1

Deploying a website using Dashboard . . . . . . . . . . . . . . . . . . . . . .

66

8.2

Creating your first group website . . . . . . . . . . . . . . . . . . . . . . . . .

68

8.2.1

Using git doesnt solve all your group working problems! . . . . . . .

68

8.3

Learning more about Git and PHP . . . . . . . . . . . . . . . . . . . . . . . . .

69

8.4

Assessment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

70

These notes are available online at


studentnet.cs.manchester.ac.uk/ugt/COMP10120/labscripts/101lab8.pdf

Most of this session will require you to work together in your tutorial group, so please
arrange to be sitting near each other in the lab.
This exercise is about understanding some of the differences between development and deployment of code, and starting to look at some of the tools that youll be using to help coordinate your work collaboratively as a team when you begin to develop your group project.

8.1

Deploying a website using Dashboard

In the exercises weve given you so far, youve been creating and editing web pages on your
Raspberry Pi, and also using the same setup to show off your finished product to lab staff or
friends. This has been fine for the relatively simple tasks youve been given up until now, and
works okay in the slightly artificial, controlled environment of our labs. But its not how webbased systemsor indeed computer systems in generalget built in the real world. Youll
learn a lot more about software engineering principles and processes in your second year, so
for now well just briefly introduce a couple of simple ideas.
So far youve been creating and modifying your web pages on your Raspberry Pi, and also
using the same setup to show your final work when you want to get it marked. The advantage
of this way of working is that its simple to set up and understand. The downside of this
approach is that while you are in the middle of developing your website and are busy creating
and editing files, any mistakes or errors you introduce are visible to anybody else looking at

November 4, 2014

66

COMP10120

Group website

your website as well. Up until now weve not really expected or cared about other users of
your site; but as you progress towards finishing your group project, or even want to have
intermediate working versions of your site that you can share with other members of your
group, then this becomes very important.
The simple solution to this problem is to have two or more versions of your system: the first
is your development setup which is for your own personal use and where anybody viewing
it should expect to see broken or unfinished content (youll probably end up with one of these
for each person in the group); and a deployment setup which real users get to see, and where
youd expect everything to be working all the time.
From now on you should think of any web pages that you create on your Raspberry Pi as
being part of your development process; in this session were going to show you how use git
and GitLab to co-ordinate code thats being developed by a group of people, and then how to
publish your groups pages to the Schools deployment server.
Well start by publishing the web pages youve already made to the deployment server.
Create yourself a new project in GitLab called something like DeploymentTest, and
clone this into your home directory on your Raspberry Pi (do not put this in your COMP10120
directory, because thats already under version control in another project and youll get
in a muddle).
Add some test HTML and/or PHP pages into this project on your Pi (youre welcome
to reuse anything from previous exercises for this purposeits just so that youve got
some content to publish).
Test these by making suitable symbolic links from /var/www on your Pi and viewing
them using the web server on the Pi.
Once you are happy that everything is working, commit and push your content back to
GitLab. You should never commit and push code until its been tested locally.
Log into your Dashboard account at:
https://web.cs.manchester.ac.uk/dashboard/
and follow the instructions for Web Publishing to select the project youve created in
GitLab and publish that to the Schools web server.
Confirm that you can see your website via the appropriate URL on the Schools server
(you can find what the URL for this is in the Dashboard instructions).
Make a change to one of your files on the Pi, and push that change to the deployment
server to confirm that you understand the process.
When youre happy that you understand the idea of using git to push changes to the Schools
deployment web server, youre ready to move on to the second part of this exercise, where
youll be working together with other people in your tutorial group. If you are the first person
from your group to reach this point, feel free to help others to achieve the same thing. Make
sure you help them to understand what they are doing though, dont just do it for them!

November 4, 2014

67

COMP10120

8.2

Group website

Creating your first group website

Working as a group rather than individually, youre now going to create a shared group website, by combining parts of the individual websites you have created for the previous lab exercises and adding some extra features:
One member of your group (it doesnt matter who) should create a new project in GitLab
which will be used for this sessions group activity. On the right-hand side of the projects
page on GitLab you will find a button with + that accesses a drop-down menu. Use the
Team Member to add all the other members of your tutorial group to the project as
Developers. All members of the group should now be able to clone this project. Make
sure you clone this somewhere that isnt currently under git control, for example you
could put it in your home directory, but not in your COMP10120 directory. Confirm that
this works before moving on.
Your group has been given access to a shared database that can be accessed via the
Dashboard. Follow the instructions at:
https://wiki.cs.manchester.ac.uk/index.php/Web_Dashboard/Database
to work out how to use PHP to access this shared database. You will need to add the fragment of code shown on the Dashboard page to your config.inc.php file; this contains
an array called $group_dbnames, in which there is one entry that contains the name of
your groups database. You will then be able to refer to this database in your PHP code
using $group_dbnames[0] without risking someone seeing what your database is called
if they look at the PHP source code for your pages. The database can be accessed using
the password of any group member.
Create a group website that allows new and existing users to log-in, using their name
and email address, and which contains the personal home pages of each of the groups
members. For the login pages, you are welcome to use code created by one member of
the group if you think they have done a particularly good job of it; alternatively you
can pick and choose bits from each members login code. Because all members of the
group should have access to the same shared project by now, each member should be
able to add their own personal pages and commit and, once they have tested them locally as
described earlier, push those to the project. It is sensible to arrange the personal pages in
subdirectories of the project so that you dont get clashes on commonly used filenames
such as index.php etc. Please dont cheat by emailing the pages all to one person and
getting them to add them all to the projectthat would rather defeat the purpose of
the activity; and remember, git will keep track of who did what, so it will be obvious if
youve done this!
Each member of the group should then be able to deploy this group website to the
schools server using Dashboard; instructions on how to do this are in the Dashboard
page itself.

8.2.1

Using git doesnt solve all your group working problems!

Please read and take notice the advice in this subsection, it is extremely important.

November 4, 2014

68

COMP10120

Group website

Figure 8.1
This time, XKCD points out how not to do things. Reproduced from http://xkcd.com/
327/ under Creative Commons Attribution-NonCommercial 2.5 License.

Now that youre starting to use git to help combine the efforts of several people, youll find
that you need to coordinate your activities in the real world in order for your git usage to
work smoothly. In particular you should note that if someone else has pushed new content
to the shared repository since you last did a clone or a pull, you wont be able to push your
material there without first doing a pull to bring your local copy of the project up to date. And
if you have modified the same files locally as ones that were modified in the repository, git will
complain that you cant carry on without working out how to merge the changes from those
two sources. You can avoid this complication for now by simply arranging not to be making
changes to the same file as someone else: although git will help with the complex problem of
joint code development, it is not a substitute for coordinating your development as a group.
Its also a good idea to heed the warning shown in figure 8.1.

8.3

Learning more about Git and PHP

Now that youve started to use git and GitLab as collaborative tools, you are moving from very
basic to more sophisticated version control. Theres still a long way to go before you master
these tools, but dont worry, things will start to make more sense as you practise more. If you
are finding any of the version control concepts hard to follow, an excellent book called Git Pro
is available for free on line at:
http://git-scm.com/book
and is well worth a read.
Also, as you start to develop more PHP skills, youre probably going to need to hone your
PHP debugging abilities too; weve started to collect some hints and tips on how to debug
PHP programs at:
https://wiki.cs.manchester.ac.uk/index.php/Php_debugging_tips

November 4, 2014

69

COMP10120

8.4

Group website

Assessment

The only file we need you to submit for this lab is a copy of the log from git. To do this, one
of you should create a directory ex8 in your COMP10120 directory and then, after going to the
directory containing your group website repository, run the command
$ git log > ~/COMP10120/ex8/group-git-log
They can then run submit and labprint as usual in the ex8 directory. Only one submission
and labprint is required for each tutorial group.
submit
You can view a copy of the marking scheme used by submit and labprint at
studentnet.cs.manchester.ac.uk/ugt/lp/ms.php?unit=COMP10120&ex=ex8.xml

November 4, 2014

70

Das könnte Ihnen auch gefallen