Yii2 Application Development Cookbook 3rd Edition Alexander Makarov download
Yii2 Application Development Cookbook 3rd Edition Alexander Makarov download
https://ebookfinal.com/download/yii2-application-development-
cookbook-3rd-edition-alexander-makarov/
https://ebookfinal.com/download/android-application-development-for-
dummies-3rd-edition-michael-burton/
https://ebookfinal.com/download/xamarin-4-x-cross-platform-
application-development-3rd-edition-jonathan-peppers/
https://ebookfinal.com/download/chef-cookbook-3rd-edition-matthias-
marschall/
https://ebookfinal.com/download/iphone-application-development-for-
dummies-4th-edition-neal-goldstein/
Android Application Development For Dummies 2nd Edition
Michael Burton
https://ebookfinal.com/download/android-application-development-for-
dummies-2nd-edition-michael-burton/
https://ebookfinal.com/download/pyside-gui-application-development-
python-2nd-edition-gopinath-jaganmohan/
https://ebookfinal.com/download/magento-1-8-development-cookbook-2nd-
new-edition-edition-delvaux/
https://ebookfinal.com/download/professional-nfc-application-
development-for-android-1st-edition-vedat-coskun/
https://ebookfinal.com/download/beginning-android-4-application-
development-1st-edition-wei-meng-lee/
Yii2 Application Development Cookbook 3rd Edition
Alexander Makarov Digital Instant Download
Author(s): Alexander Makarov, ; Bogdanov, Andrew; Dmitry Eliseev
ISBN(s): 9781785281495, 1785281496
Edition: 3rd
File Details: PDF, 5.25 MB
Year: 2016
Language: english
Yii2 Application
Development Cookbook
Third Edition
Discover 100 useful recipes that will bring the best out of
the Yii2 framework and be on the bleeding edge of web
development today
Andrew Bogdanov
Dmitry Eliseev
BIRMINGHAM - MUMBAI
Yii2 Application Development Cookbook
Third Edition
All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78528-176-1
www.packtpub.com
Credits
Authors Copy Editor
Andrew Bogdanov Tom Jacob
Dmitry Eliseev
Project Coordinator
Reviewer Judie Jose
Maurizio Domba Cerin
Proofreader
Commissioning Editor Safis Editing
Ashwin Nair
Indexer
Acquisition Editors Pratik Shirodkar
Vivek Anantharaman
James Jones Graphics
Kirk D'Penha
Aaron Lazar
Production Coordinator
Content Development Editor
Deepika Naik
Sanjeet Rao
Cover Work
Technical Editors
Deepika Naik
Bhagyashree Rai
Nidhisha Shetty
About the Authors
Andrew Bogdanov is a seasoned web developer from Yekaterinburg, Russia with more
than six years of experience in industrial development. Since 2010 he has been interested in
Yii and MVC frameworks. He has taken part in projects written in Yii such as a work aggregator
for a UK company, high-load projects, real-estate projects, and development of private projects
for the government.
He has worked on various CMS and frameworks using PHP and MySQL, which includes
Yii, Kohana, Symphony, Joomla, WordPress, CakePHP, and so on. Also, having good hands
in integrating third-party APIs such as Payment gateways (Paypal, Facebook, Twitter, and
LinkedIn), he is very good in slicing and frontend. So he can provide full information about
Yii framework.
He is also well-versed in PHP/MYSQL, Yii 1.x.x, Yii 2.x.x, Ajax, JQuery, MVC frameworks,
Python, LAMP, HTML/CSS, Mercurial, Git, AngularJs, and adaptive markup. You can
also visit his blog http://jehkinen.com.
In his free time he likes to visit and talk with new people and discuss web development
problems. He is currently working with professionals http://2amigos.us.
Dmitry Eliseev has been a web developer since 2008 and specializes in server-side
programming on PHP and PHP frameworks.
Since 2012 he has authored his personal blog, http://elisdn.ru, about web
development in general and about the Yii Framework particularly. His blog became a
well-known resource in the Russian Yii community. He is an active member of a
Russian-language forum http://yiiframework.ru.
Maurizio Domba Cerin is a frontend and backend web developer with over 24 years
of professional experience in computer programming and 13 years in web development.
He is an active member of the Yii community. At the moment he is developing intranet
web applications for an export-import enterprise and working on other international
projects, always trying to help others to improve their code and project usability. When not
programming the Web, he is programming his wife and kids, always with a smile on his face,
open-hearted and open-minded. He loves climbing, martial arts, meditation, and salsa.
www.PacktPub.com
At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt
books and video courses, as well as industry-leading tools to help you plan your personal
development and advance your career.
Why Subscribe?
ff Fully searchable across every book published by Packt
ff Copy and paste, print, and bookmark content
ff On demand and accessible via a web browser
Table of Contents
Preface v
Chapter 1: Fundamentals 1
Introduction 1
Installing the framework 2
Application templates 6
Dependency injection container 7
Service locator 19
Code generation 27
Configuring components 32
Working with events 34
Using external code 38
Chapter 2: Routing, Controllers, and Views 45
Introduction 46
Configuring URL rules 46
Generating URLs 49
Using regular expressions in URL rules 55
Using a base controller 59
Using standalone actions 63
Creating a custom filter 71
Displaying static pages 74
Using flash messages 77
Using the controller context in a view 83
Reusing views with partials 84
Using blocks 88
Using decorators 91
Defining multiple layouts 92
Pagination and sorting data 97
i
Table of Contents
ii
Table of Contents
Rate limiting 260
Versioning 265
Error handling 268
Chapter 7: Official Extensions 271
Introduction 271
Authentication client 271
SwiftMailer e-mail library 277
Faker fixture data generator 283
Imagine library 286
MongoDB driver 288
ElasticSearch engine adapter 296
Gii code generator 300
Pjax jQuery plugin 308
Redis database driver 311
Chapter 8: Extending Yii 315
Introduction 315
Creating helpers 316
Creating model behaviors 318
Creating components 326
Creating reusable controller actions 332
Creating reusable controllers 337
Creating a widget 342
Creating CLI commands 346
Creating filters 351
Creating modules 357
Creating a custom view renderer 364
Creating a multilanguage application 368
Making extensions distribution-ready 376
Chapter 9: Performance Tuning 379
Following best practices 379
Speeding up session handling 383
Using cache dependencies and chains 386
Profiling an application with Yii 396
Leveraging HTTP caching 403
Combining and minimizing assets 415
Running Yii2 on HHVM 421
iii
Table of Contents
iv
Preface
Yii is a free, open source web application development framework, written in PHP5, that
promotes clean DRY design and encourages rapid development. It works to streamline your
application development time and helps to ensure an extremely efficient, extensible, and
maintainable end product. Being extremely performance-optimized, Yii is a perfect choice for
any size project. However, it has been built with sophisticated, enterprise applications in mind.
You have full control over the configuration from head-to-toe (presentation-to-persistence) to
conform to your enterprise development guidelines. It comes packaged with tools to help test
and debug your application, and has clear and comprehensive documentation.
This book is a collection of Yii2 recipes. Each recipe is represented as a full and independent
item, which showcases solutions from real web applications. So you can easily reproduce
them in your environment and learn Yii2 fast and without tears. All recipes are explained
with step-by-step code examples and clear screenshots. Yii2 is like a suit that looks great
off the rack, but is also very easy to tailor to fit your needs. Virtually every component of
the framework is extensible. This book will show how to use official extensions, extend any
component, or write a new one.
This book will help you create modern web applications quickly, and make sure they perform
well using examples and business logic from real life. You will deal with the Yii command line,
migrations, and assets. You will learn about role-based access, security, and deployment. We'll
show you how to easily get started, configure your environment, and be ready to write web
applications efficiently and quickly.
v
Preface
Chapter 2, Routing, Controllers, and Views, teaches some handy things about the
Yii URL router, controllers, and views. You will be able to make your controllers and
views more flexible.
Chapter 3, ActiveRecord, Model, and Database, discusses the three main methods to work
with databases in Yii: Active Record, query builder, and direct SQL queries through DAO. All
three are different in terms of syntax, features, and performance. In this chapter we will learn
how to work with the database efficiently, when to use models and when not to, how to work
with multiple databases, how to automatically preprocess Active Record fields, and how to use
powerful database criteria.
Chapter 4, Forms, covers how Yii makes working with forms a breeze and the documentation
on it is almost complete. Still, there are some areas that need clarification and examples.
Chapter 5, Security, discusses how to keep your application secure according to the general
web application security principle "filter input, escape output." We will cover topics such as
creating your own controller filters, preventing XSS, CSRF, and SQL injections, escaping output,
and using role-based access control.
Chapter 6, RESTful Web Services, covers how to write RESTful Web Services using Yii2 and
built-in features.
Chapter 7, Official Extensions, explains us how to install and use official extensions in your
project. You will learn how to write your own extension and share it for another developers.
Chapter 8, Extending Yii, covers not only how to implement your own Yii extension, but also
how to make your extension reusable and useful for the community. In addition, we will focus
on many things you should do in order to make your extension as efficient as possible.
Chapter 9, Performance Tuning, teaches some best practices of developing an application
that will run smoothly until you have very high loads. Yii is one of the fastest frameworks
out there. Still, when developing and deploying an application, it is good to have some extra
performance for free, as well as following best practices for the application itself. In this
chapter, we will see how to configure Yii to gain extra performance. In addition, we will learn
some best practices for developing an application that will run smoothly until we have very
high loads.
vi
Preface
Chapter 10, Deployment, covers various tips, which are especially useful on application
deployment and when developing an application in a team, or when you just want to make
your development environment more comfortable.
Chapter 11, Testing, teaches us how to use the best technologies for testing such as
Codeception, PhpUnit, Atoum, and Behat. You will be introduced how to write simple tests and
how to avoid regression errors in your applicaiton.
Chapter 12, Debugging, Logging, and Error Handling, discusses review logging, analyzing the
exception stack trace, and implementing our own error handler. It is not possible to create a
bug-free application if it is relatively complex, so developers have to detect errors and deal
with them as fast as possible. Yii has a good set of utility features to handle logging and
handling errors. Moreover, in the debug mode, Yii gives you a stack trace if there is an error.
Using it, you can fix errors faster.
ff Database server
ff PHP
ff Yii2
Sections
In this book, you will find several headings that appear frequently (Getting ready, How to do
it..., How it works..., There's more..., and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
Getting ready
This section tells you what to expect in the recipe, and describes how to set up any software or
any preliminary settings required for the recipe.
vii
Preface
How to do it…
This section contains the steps required to follow the recipe.
How it works…
This section usually consists of a detailed explanation of what happened in the
previous section.
There's more…
This section consists of additional information about the recipe in order to make the reader
more knowledgeable about the recipe.
See also
This section provides helpful links to other useful information for the recipe.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of
information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "we are
defining an alias parameter that should be specified in the URL after /page/."
When we wish to draw your attention to a particular part of a code block, the relevant lines or
items are set in bold:
'urlManager' => array(
'enablePrettyUrl' => true,
'showScriptName' => false,
),
viii
Preface
New terms and important words are shown in bold. Words that you see on the screen, for
example, in menus or dialog boxes, appear in the text like this: "Generate a Post model using
Gii with an enabled Generate ActiveQuery option that generates the PostQuery class."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book—what you liked or disliked. Reader feedback is important for us as it helps us
develop titles that you will really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to
get the most from your purchase.
ix
Preface
1. Log in or register to our website using your e-mail address and password.
2. Hover the mouse pointer on the SUPPORT tab at the top.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box.
5. Select the book for which you're looking to download the code files.
6. Choose from the drop-down menu where you purchased this book from.
7. Click on Code Download.
Once the file is downloaded, please make sure that you unzip or extract the folder using the
latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/
PacktPublishing/Yii2-Application-Development-Cookbook-Third-Edition.
We also have other code bundles from our rich catalog of books and videos available at
https://github.com/PacktPublishing/. Check them out!
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you could report this to us. By doing so, you can save other
readers from frustration and help us improve subsequent versions of this book. If you find
any errata, please report them by visiting http://www.packtpub.com/submit-errata,
selecting your book, clicking on the Errata Submission Form link, and entering the details of
your errata. Once your errata are verified, your submission will be accepted and the errata will
be uploaded to our website or added to any list of existing errata under the Errata section of
that title.
x
Preface
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At
Packt, we take the protection of our copyright and licenses very seriously. If you come across
any illegal copies of our works in any form on the Internet, please provide us with the location
address or website name immediately so that we can pursue a remedy.
We appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at questions@
packtpub.com, and we will do our best to address the problem.
xi
Discovering Diverse Content Through
Random Scribd Documents
his revenue at £69,340,000, and the actual income was £69,600,000. But the
expenditure, instead of being only £68,134,000, as estimated, reached
£71,759,000. Deducting £2,000,000 charged that year to the war, the
ordinary expenditure still exceeded the estimate by fully a million and a half,
about £700,000 of which was due to the increased cost of civil
administration.”[261] Hence the
people said that the old ill-luck of the Tories in finance followed them still.
The days of plump surpluses had vanished, and those of growing
expenditure and dismal deficits had begun. The only remission of taxation
which Mr. Disraeli proposed was the reduction of the Marine Insurance
Duties. The Budget, in fact was a tribute to those who, like Mr. Mill and Mr.
Stanley Jevons, had impressed the public mind that the time had come when
sacrifices must be made not to reduce taxes, but to pay off National Debt.
LORD NAAS (AFTERWARDS EARL OF MAYO).
The Session of 1867 was not prolific in Irish legislation. Ministers and
private members once more made futile attempts to unravel the tangled web
of the Land Tenure question. One measure, indeed, of a vigorous and
decided character, was rapidly passed, namely, the Act for continuing for
three months the suspension of the Habeas Corpus in Ireland. But as to land
tenure, Lord Naas, on behalf of the Government, introduced a Bill very early
in the Session to promote the improvement of land by tenants. The Bill was
founded on the principle of the Lands Improvement Act. There were several
kinds of improvements, for the making of which money was advanced under
the Lands Improvement Act. These were, thorough draining, the reclamation
of waste lands, the removal of old and useless fences, the making of farm
roads, and the erection of farmhouses, dwellings, and other buildings. On the
Second Reading of Lord Naas’ Bill being moved, a considerable diversity of
opinion was exhibited with respect to the tendency and operation of the
measure. Several amendments were proposed and discussed at length, and
the debate was adjourned. Owing, partly to the pressure occasioned by the
Reform debates, and other questions, and partly to a general impression of
the futility of attempting to carry a measure of this description, the Bill was
dropped.
Another effort was made, with similar results, by the Marquis of
Clanricarde, who laid on the table of the House of Lords a Bill for giving
facilities for voluntary contracts between landlords and tenants in Ireland.
The Bill did not obtain a second reading. A third attempt to deal with the
difficulty was made by Sir Colman O’Loghlan, who obtained leave to bring
in a Bill, its main object being to encourage the granting of leases, and to
discourage tenancies at will. After much controversy this measure was also
dropped, and the Irish people read the old moral from these debates, that
they must look elsewhere than to Parliament for the redress of their
grievances. An effort was now made to raise the Irish Church Question. Sir
John Gray, on the 7th of May, moved that the House of Commons on a
future day resolve itself into committee to consider the temporalities and
privileges of the Established Church in Ireland. This was a motion that was
not unattractive to the Whigs, and so Colonel Greville seconded it as a
Protestant who, living in Ireland, felt it his duty to protest in the strongest
manner against the continuance of an unjust establishment. Sir Frederick
Heygate moved the previous question, and then Mr. Gladstone intervened,
giving a hint of his coming Irish policy. He found a difficulty in supporting
the Resolution, not because he questioned the soundness of it, but because it
was an abstract Resolution, and the House ought not to pass it without
having a plan for giving effect to it. We might, he contended, support a
religious establishment to maintain truth, but we did not support the Irish
Protestant establishment for that purpose only, seeing that we also supported
the Catholic College of Maynooth. We might maintain an established church
because its doctrines were those of the bulk of the people. But that was
notoriously not the case in Ireland. We might keep up an established church
to supply the poorest class of the community with free and cheap religious
teaching. But the Protestant Church in Ireland was the church of the rich. He
trusted the time was not far distant when Parliament would take the question
of the Irish Church up; and when it did he hoped that “a result would be
arrived at which would be a blessing to all.” This speech, coming from the
author of the celebrated work in defence of established churches, was
listened to with consternation by the Tories. They began to regret that they
had “unmuzzled” Mr. Gladstone, to use Palmerston’s phrase, by turning him
out of Oxford. The matter was, however, shelved for a time, the “previous
question” being carried by a majority of 195 to 183.
That the attack was preconcerted by the Liberal leaders was indicated by
the fact that in the House of Lords Earl Russell, on the 24th of June, moved
an address to the Queen, praying her to order, by Royal Commission, or
otherwise, full information to be procured as to the revenues of the
Established Church in Ireland, with a view to their more equitable
application for the benefit of the Irish people. Lord Russell hinted that he
favoured the application to Ireland of the voluntary principle, and if that
were done he would appropriate the property of the Church to educational
purposes. Lord Cairns, however, declared that the destruction of the
Established Church, whose function it was to teach Christian truth, would be
fatal to the landed interest, and to the commerce of Ireland with England.
But a motion for an address praying simply for a Royal Commission was
agreed to, and the Commission was issued by the Crown in the ensuing
autumn. Meantime, as the Times wrote in 1865, Ireland was “being cleared
quietly for the interests and luxury of humanity.” And yet not too quietly.
The progress of Fenianism, especially in the British Army, was wonderfully
rapid. Hundreds of agitators were carrying on their secret propaganda.
Scores of Irish-American officers were pouring into Ireland, telling the
people that General Sheridan and other hot-headed soldiers of their race in
the United States were eager to interfere on their behalf. Early in 1867
sporadic risings of small, half-armed mobs were put down with ease, and in
the trials which followed the capital sentence passed on those found guilty
was commuted to one of penal servitude, the abstinence of the rebels from
wanton outrage giving the Queen a reasonable ground for exercising her
prerogative of mercy. But the Fenian organisation had grown to unexpected
strength in England, and within a few days after Ministers announced the
Bill suspending Habeas Corpus in Ireland (11th of February) a band of men,
headed by Irish-American officers, would have surprised and seized the
arsenal of Chester Castle, with its 20,000 stand of arms, had not their design
been divulged by treachery. In autumn an event occurred which has to this
day been the matter of hot controversy between Irishmen and Englishmen.
The leadership of the Fenian conspiracy had now passed into the hands of a
Colonel Kelly, who succeeded Mr. Stephens. He was returning from a
meeting at Manchester with his friend Captain Deasy, and they were both
arrested by the police on suspicion of loitering for purposes of burglary.
They gave false names, but it was soon discovered who they were. The
Fenians of Manchester resolved to rescue them, and on the 18th of
September the prison van in which Kelly and Deasy were being conveyed to
Salford was attacked by a body of thirty armed men. The horses were shot.
The escort ran away, and the Fenians then ordered Police Sergeant Brett,
who was on duty inside the van to unlock the door. He refused, and a pistol
was fired at the lock, in order to break it. Unfortunately, the bullet struck
Brett, who died from the wound. Kelly and Deasy made their escape, and
were heard of no more. But in the meantime a crowd had gathered, and had
nearly stoned to death William Philip Allen, one of the rescuing party,
several of whom, including men called Larkin, Maguire, O’Brien (alias
Gould), and Condon (alias Shore), were captured and tried for the murder of
Sergeant Brett. They were all sentenced to be hanged, though the evidence
against them was somewhat faulty. One of the prisoners (Maguire) was
undoubtedly arrested by mistake, and the newspaper reporters who were
present at his trial petitioned for his release. On further investigation it was
found that the reporters were right, and the man was set free. But three of the
prisoners were executed on the 23rd of November, although they protested
they had not the remotest idea of hurting Sergeant Brett. “Condon,” writes
Mr. T. P. O’Connor, M.P., “in speaking, used a phrase that has become
historic: ‘I have nothing,’ he said, in concluding his speech, ‘to regret or to
take back. I can only say, ‘God save Ireland.’ His companions advanced to
the front of the dock, and, raising their hands, repeated the cry, ‘God save
Ireland’ ”[262]—a phrase that became the shibboleth or watchword of the
Irish Nationalist Party. Condon was reprieved because he was an American
citizen. Numbers of eminent Englishmen—headed by Mr. John Bright, Mr.
Mill, and Mr. Swinburne—endeavoured to get the others reprieved also, but
in vain. Allen, Larkin, and O’Brien were hanged on the 23rd of November,
and their execution produced a profound impression on the Irish race all over
the world. In the towns in Ireland great and solemn funeral processions
marched through the streets. Mr. T. D. Sullivan wrote the poem “God save
Ireland,” which displaced the National Anthem at Irish political gatherings.
“To an Irishman,” writes Mr. O’Connor, “then a youth, living in the country
house of his fathers, and deeply immersed in the small concerns of a squire’s
daily life, the execution of the Manchester martyrs was a new birth of
political convictions. To him, brooding from his early days over the history
of his country, this catastrophe came to crystallise impressions into
conviction, and to pave the way from dreams to action. It was the execution
of Allen, Larkin, and O’Brien that gave Mr. Parnell to the service of
Ireland.”[263] But another event happened which made it clear that the
Fenian conspiracy was still formidable. One of its leaders, an Irish-American
officer named Burke, had been captured and cast into Clerkenwell gaol, and
his friends resolved to rescue him. Their agents, on the 13th of December,
placed a barrel of gunpowder opposite the exercising ground of the gaol,
where General Burke was supposed to be walking at the time. They then
blew down the wall. Fortunately for himself, the Government had learned
that a rescue was to be attempted, and the General had accordingly been
removed to another part of the prison, otherwise he would have been killed.
The victims were poor people who lived in the houses opposite the gaol, of
whom twelve were killed and one hundred and twenty shockingly injured.
An ignorant Fenian named Barrett was convicted of having been implicated
in this clumsy plot, and was tried and executed in front of Newgate. This
outrage ruined the Fenian organisation, not only in England but in Ireland.
Many honest Irishmen, who in a fit of patriotic enthusiasm had joined its
ranks, withdrew from a body whose deep and dark designs they saw were
apt to be carried out with the stupid brutality that marked the Clerkenwell
outrage.
THE QUEEN LAYING THE FOUNDATION STONE OF THE ROYAL ALBERT HALL. (See p.
292.)
But the Fenians were not the only outragemongers who frightened the
comfortable classes out of their senses in 1867. The skilled artisans in many
cases had employed their trade organisations to coerce by violence masters
who refused to yield to the demands of their workmen, and workmen who
refused to obey the orders of their Unions. Early in the year a Commission
had been appointed to consider the legal position of the Unions, which was
most unsatisfactory, and a separate Commission, appointed to investigate
outrages which had been perpetrated at Sheffield, made some astounding
revelations. They reported that the officials of the Sawgrinders’ Union had
hired assassins to maim, murder, or torture people who thwarted the policy
of the Union.[264] They reported that similar barbarities were practised by
the officials of the Brickmakers’ and Bricklayers’ Unions in Manchester. The
country rang with denunciations of the working classes, and “strikes,” such
as that of the London tailors, were carried on with unparalleled acrimony.
War between “the two nations,” to use Mr. Disraeli’s phrase in “Sybil,” was
imminent. It is curious to observe how seldom public writers and speakers
on the conflict between Labour and Capital which then raged, took the
trouble to ascertain the precise position of the artisans in the struggle. The
truth, however, had been told with uncompromising honesty by the
Committee of the House of Commons, who in 1821 had reported that
outlawry made Trades Unionists lawless. In that year it was true an Act had
been passed to legalise workmen’s combinations for improving wages and
reducing the hours of labour. But then this Act gave the preference to the
word of the master in any dispute between him and his servant, and pedantic
judges had made it a dead letter, by ruling that “all combinations in restraint
of trade” were criminal. Nor had they stopped here. They roused the wrath
of the working classes to white heat in 1867, by ruling in the case of Hornby
v. Close that Trades Unions could not even hold property or funds for
benevolent purposes. In fact, at that period, the position of the English
working man was one of almost servile degradation, and under an extended
franchise such a state of things could not last long. On the 5th of March a
Conference of Trades Unionists was held in St. Martin’s Hall, London, to
protest against the decision in Hornby v. Close, a meeting which was the
germ of the great Trades Union Congress, that ultimately became a mighty
power in the industrial world.[265]
Early in the year the Queen received with pleasure the intimation that
Prince Arthur had passed his military examination in a manner that did him
great credit. “I am delighted,” writes the Princess Louis to the Queen on the
13th of January,[266] “to hear of dear Arthur having passed so good an
examination. How proud you must be of him! And the good Major,[267] who
has spared no pains, I know—how pleased he must be! Arthur has a uniform
now, I suppose.” From another passage in a letter of the Princess’s, one
gathers that the cloud of melancholy which overhung the Queen’s widowed
life was beginning to disappear. “I think,” says the Princess, replying to one
of the Queen’s letters on the subject, “I can understand what you must feel. I
know well what those first three years were—what fearful sufferings, tearing
and uprooting those feelings which had been centred on beloved papa’s
existence! It is indeed as you say ‘a mercy’ that after the long storm a lull
and calm ensues, though the violent pain which is but the reverse of the
violent love seems only to die out with it, and that is likewise better. Yet,
beloved mamma, could it be otherwise? There would be no justice or mercy,
were the first stage of sorrow to be the perpetual one.” Still, the advancing
year brought its own cares to the Royal Family. A Princess was born to the
Prince and Princess of Wales on the 20th of February, and though the official
announcements stated that both mother and child were doing well, this was
by no means the case. The recovery of the Princess was not satisfactory, and
the physicians at last had to admit that she was suffering from a peculiarly
obstinate rheumatic attack, that sadly undermined her health and strength.
The Queen had, as usual, confided her anxieties to her daughter at
Darmstadt, who in reply wrote as follows:—“The knowledge of dear sweet
Alix’s[268] state makes me too sad. It is hard for them both, and the nursing
must be very fatiguing for Mrs. Clarke. I am so distressed about darling Alix
that I really have no peace. It may and probably will last long, which is so
dreadful.” On the 14th of April the accouchement of the Princess Christian
took place, when she was safely delivered of a little Prince, the Queen being
in close attendance by her bedside all day.
On the 20th of May the Queen laid the first stone of the Hall of Arts and
Sciences at Kensington, now known as the Royal Albert Hall. It was
intended, and has since been used, for scientific and artistic congresses, both
national and international; performances of music, distribution of prizes by
public bodies, agricultural, horticultural, and industrial exhibitions, and
displays of pictures and sculpture. At the inaugural function 7,000 visitors
were arranged in an oval amphitheatre richly draped, and gay with the bright
summer costumes of the ladies, and with gorgeous official uniforms. Among
the guests were the Foreign Ministers wearing their decorations, the Lord
Mayor and Aldermen in their robes, Lord Derby, Mr. Disraeli, and other
Ministers and Ex-Ministers. The foundation stone bore in gold letters the
inscription, “This stone was laid by her Most Gracious Majesty Queen
Victoria, May 20, 1867.” Accompanied by Princesses Louise and Beatrice
the Queen arrived at the entrance of the building at Kensington Gore at half-
past eleven, where the Prince of Wales and the Duke of Edinburgh met the
party. After receiving an address read by the Prince of Wales, her Majesty
made the following reply, but, contrary to her usual habit, in a scarcely
audible tone of voice:—
“I thank you for your affectionate and dutiful address. It has been with a struggle that I
have nerved myself to a compliance with the wish that I should take part in this day’s
ceremony; but I have been sustained by the thought that I should assist by my presence
in promoting the accomplishment of his great designs, to whose memory the gratitude
and affection of the country are now rearing a noble monument, which I trust may yet
look down on such a centre of institutions for the promotion of Art and Science as it
was his fond hope to establish here. It is my wish that this hall should bear his name, to
whom it will have owed its existence, and be called ‘The Royal Albert Hall of Arts and
Sciences.’ ”
On the 13th of July the Sultan Abdul Aziz arrived in London. On the
following day he visited Windsor. The Queen with the younger members of
the Royal Family received his Majesty in the Grand Hall, and on his
alighting she advanced to meet him. He stepped forward with an Eastern
salutation, and kissed her hand, and in the interchange of courtesies which
ensued, the Queen affectionately kissed his Highness, the young Izzedin
Effendi, the Sultan’s son, as did also the Princess Mary of Teck. The Grand
Turk was indeed the lion of the London season of 1867, for Society was en
fête in his honour. On the evening of the 19th, after being entertained at a
splendid banquet given by the Duke of Cambridge, he attended a grand ball
given by the Secretary of State for India. The members of the Indian Council
led the procession in a body by themselves, and Sir Stafford Northcote then
preceded the august party, at the head of which walked the Sultan, with the
Princess Louis of Hesse on his arm. In the brilliant train that followed
Moslem and Christian Princes were strangely intermixed. The ball was
opened by Sir Stafford Northcote and the Princess Louis, who led off the
first quadrille, the Sultan looking on the scene with melancholy gravity, as if
it were a show got up for his diversion. He, however, did full justice to the
sumptuous supper, after which refreshment he returned to the ball-room, and
about two o’clock took his departure, followed by the more distinguished
guests. The scene at the India Office had been brilliant as one in Fairyland.
But it was marred by one sad incident. Madame Musurus, the wife of the
Turkish Ambassador, when taking some friends into supper suddenly
dropped down dead. On the 20th the Sultan visited the Volunteer Camp at
Wimbledon, and on the 22nd he was entertained by the Duke of Sutherland,
and day after day the town was kept in a state of giddy excitement by the
uninterrupted succession of spectacles and entertainments provided in
honour of the Queen’s Oriental guests. On the 23rd his Majesty left
Buckingham Palace, where he had resided twelve days, and amidst the
cheering of the populace took his departure for Dover. His visit rather
obscured that of the Viceroy of Egypt, who was the guest of the nation at the
same time, and was entertained by the Queen at Windsor on the 8th of July.
Besides the melancholy and tragic death of Madame Musurus there was
only one other disagreeable incident attached to the Sultan’s visit. A grand
naval review at Portsmouth was arranged for his delectation and instruction
on the 17th of July. It was known that the Queen intended to confer a mark
of distinction on her Imperial visitor, but it was whispered that he was
dissatisfied with what her Majesty proposed to do for him. The whole story
has since been told by Lord Malmesbury, who says that at first the Queen, at
Lord Derby’s suggestion, offered to confer on Abdul Aziz the Star of India.
But Fuad Pasha, who was in attendance on Abdul Aziz, hearing of this went
to the Lord Steward and warned him that the Sultan would consider himself
slighted if he were offered anything but the Garter. Already he had the Bath,
and he seemed to consider the Star of India as an inferior distinction to the
Bath. Lord Derby was remonstrated with, and finally it was settled that when
the Queen received the Sultan on her yacht at the Naval Review she should
give him the Order of the Garter. This was done with great pomp and
ceremony, as Lord Malmesbury says, “in the midst of the howling of the
storm and the roaring of the cannon.” But here another hitch occurred. No
ribbon was ready, so the Queen took the ribbon of Prince Louis of Hesse and
presented it to the Sultan, intending that he should return it, when a new one
could be got for him. “But,” writes Lord Malmesbury, “the Sultan refused to
give it (the ribbon) up, saying
THE QUEEN INVESTING ABDUL AZIZ WITH THE ORDER OF THE GARTER.
that the one he had was given to him by the Queen, and that he would wear
no other.”[269]
In July the Empress of the French spent a few days quietly with the
Queen at Osborne, and on the 9th of August the Queen paid a long visit to
the Royal Victoria Hospital at Netley, where she went through the wards,
speaking after her homely fashion to the sick and wounded soldiers. She
took a special interest in one case—that of a man who had been shot through
the lungs at Lucknow, in 1858, but who had continued to do duty almost
down to 1867.
In the end of the month the Queen resolved to pay a visit to the Scottish
Border, an enchanted land of romance and minstrelsy, of fairy lore, and
feudal chivalry. On the 28th of August, accompanied by Princess Louise,
Princess Beatrice, Prince Leopold, Prince and Princess Christian, and Prince
Christian Victor of Sleswig-Holstein, the Queen left Windsor Castle in the
evening for Balmoral. She broke the direct route by having her special train
stopped at Kelso, in order to visit a valued friend of the Royal Family—the
Duchess of Roxburghe. On arriving at the station, the Queen affectionately
kissed the Duchess; and her procession to Floors Castle was really a
triumphal one. In fact, nothing could have exceeded the heartiness of the
greeting which she everywhere got from the people. A vast crowd filled the
Marketplace, where her Majesty received an address from the magistrates of
Kelso. In replying to it, she said, “I thank you, Mr. Craig, and the town of
Kelso; an answer will be sent to your address.” A little girl, the daughter of
the Baron Bailie of Kelso, was then lifted up to the royal carriage, and
presented to the Queen a large bouquet, which her Majesty received with an
expression of delight. Her arrival at Floors, the seat of the Duke of
Roxburghe, was announced to the town by a royal salute, fired from
Roxburgh Castle. Great illuminations took place in Kelso at night, to the
delight of thousands of country people. On the 22nd the Queen paid a visit to
Melrose Abbey and Abbotsford. On reaching the Priory, she was received by
the Duke of Buccleuch, the proprietor of the ruins and Lord-Lieutenant of
the county. The Queen went to Jedburgh on the 23rd, and afterwards visited
Hartrigge, a place associated with Lord Chancellor Campbell’s memory.
When the royal progress through the land of Scott and Thomas the Rhymer
ended the Court proceeded to Balmoral.
This tour brightened the Queen’s spirits, which seemed to have been
slightly depressed before she left town. She had half hinted in one of her
letters to the Princess Louis that her home was losing its attractions for some
members of her family, and these suspicions the Princess promptly dispelled
in a letter written from St. Moritz. “You say,” she observes to the Queen,
“that our home is dull now for those who like to amuse themselves. It is
never dull, darling mamma, when we can be with you, for I have indeed
never met a
In October fresh domestic cares were added to the overladen life of the
Sovereign. To one of these, in a letter from Darmstadt, dated 10th October,
1867, the Princess Louis alludes as follows:—“I can’t find words to say how
sorry I am that dear, sweet Arthur[274] should have the small-pox! and that
you should have this great anxiety and worry. God grant that the dear boy
may get well over it, and that his dear handsome face be not marked. The
Major (Elphinstone) kindly telegraphs daily, and you can fancy far away
how anxious one is. I shall be very anxious to get a letter with accounts, for I
think constantly of him and of you.” And again, on the 14th, she writes:
“How glad I am to see by your letter that darling Arthur is going on so very
well. One can’t be too thankful; and it is a good thing over, and will spare
one’s being anxious about him on other occasions.” In the same letter there
is a reference to another matter which had caused the Queen some trouble.
There had been, ever since the Danish war, a coolness between the families
of her eldest son and eldest daughter, which her Majesty had strenuously
endeavoured to remove. Her conciliatory efforts were this year crowned with
success. The Prince and Princess of Wales visited the Continent, and met the
King of Prussia. “Bertie and Alix,” writes the Princess Louis, on the 14th
October, “have been here (Darmstadt) since Saturday afternoon, and leave
to-morrow. They go straight to Antwerp, and Bertie is going back to Brussels
to see the cousins. The visit of the King went off very well, and Alix was
pleased with the kindness and civility of the King (of Prussia). I hear that the
meeting was satisfactory to both parties, which I am heartily glad of. Bearing
ill-will is always a mistake, besides its not being right.”[275] The
embarrassments of the Darmstadt household, however, still continued to
grieve the Queen, to whom her daughter the Princess Louis, confided all her
troubles. The Princess had broken down in health during the autumn of
1867, and, in one of her letters she tells the Queen that as she does not
consider it prudent, “for financial reasons,”[276] to engage a governess for
her daughter, the Princess Victoria, she has asked Mr. Geyer, who taught her
little black servant Willem, “to give her a lesson every other day.”[277] On
the 18th of October the statue to the Prince Consort, at Balmoral, was
unveiled, with reference to which the Princess Louis, in one of her letters
(26th of October) expresses a hope which was fairly well realised—to the
effect that the ceremony “went off as well as the weather would permit.”
THE QUEEN KEEPING HALLOWE’EN AT BALMORAL.
The Scottish festival of Hallowe’en (31st of October) was kept this year
by the Queen with unusual formality. “We had been driving,” she writes,
“but we turned back to be in time for the celebration. Close to Donald
Stewart’s house we were met by two gillies, bearing torches. Louise got out
and took one, walking by the side of the carriage like one of the witches in
Macbeth. As we approached Balmoral, the keepers, with their wives and
children, the gillies, and other people, met us, all with torches, Brown also
carrying one. We got out at the house, where Leopold joined us, and a torch
was also given to him. We walked round the house with Ross playing the
pipes, going down the steps of the terrace. Louise and Leopold went first,
then came Jane Ely, and I followed by every one carrying torches, which had
a very pretty effect. After this, a bonfire was made of all the torches, close to
the house, and they danced reels while Ross played the pipes.”
In December, after returning from Balmoral, the Queen paid a visit to
Claremont and to Lady Palmerston. “The visit to Claremont,” writes the
Princess Louis, “must have been quite peculiar for you; and I can fancy it
bringing back to your mind the recollections of your childhood. In spring it
must be a lovely place, and with gayer papers on the walls, and a little
modern comfort, the house must likewise be very pleasant.... The account of
your visit to Lady Palmerston and to her daughter is most touching. It is so
inexpressibly sad for grandmother and mother, for it is unnatural for parents
to survive their children, and that makes the grief a so peculiar one, and very
hard to bear.”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com