Blogsonic is a simple CRUD Web Application in PHP.
Blogsonic is a simple CRUD Web Application in PHP. It could be defined as a mini Social Network that allows you to post text content (called Blogs) visible to all.
Note: The existence of Blogsonic has the sole purpose of showing a very basic example of a CRUD Web Application. This means that not much attention has been paid to the general appereance of the website and to the code and its structure. Therefore, Blogsonic should not be used as a reference point in these respects, but should be considered as a starting point for beginners from which to start understanding the basic concepts.
Blogsonic was created using the following tools and technologies:
- Front-end:
- HTML;
- CSS (framework: Bootstrap);
- JavaScript;
- jQuery;
- AJAX.
- Back-end:
- PHP (framework: CodeIgniter 3.1.11);
- MySQL.
Blogsonic also exists thanks to:
The designer and creator of Blogsonic it's me, that is Antonio Granaldi. You can see my LinkedIn profile by clicking here.
You can contact me on my LinkedIn profile above, or by sending an email to [email protected].
Of course! You can find everything you need on GitHub.
Follow the next steps to set up Blogsonic.
Create a database and add the following tables. You can also find these tables in application/tables/
.
CREATE TABLE `users` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`surname` varchar(50) NOT NULL,
`gender` varchar(1) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(50) NOT NULL,
`phone` varchar(13) NOT NULL,
`language` varchar(2) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
);
CREATE TABLE `blogs` (
`id` int NOT NULL AUTO_INCREMENT,
`user_id` int NOT NULL,
`title` varchar(20) NOT NULL,
`body` text NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
CONSTRAINT `fk_usersblogs` FOREIGN KEY (`user_id`)
REFERENCES `users`(`id`)
ON UPDATE CASCADE
ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS `sessions` (
`id` varchar(128) NOT NULL,
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
`data` blob NOT NULL,
KEY `sessions_timestamp` (`timestamp`)
);
Copy the .env.example
file in the root of the project and name it .env
.
$ cp .env.example .env
The valid variables are:
CI_ENV
: defines the current environment. The available options are:development
,testing
andproduction
. Setting the variable to a value ofdevelopment
will cause all PHP errors to be rendered to the browser when they occur. Conversely, setting the variable toproduction
will disable all error output;BLOGSONIC_BASE_URL
BLOGSONIC_ENCRYPTION_KEY
: to generate an encryption key, you can go to RandomKeygen and scroll down to "CodeIgniter Encryption Keys";BLOGSONIC_IN_EMAIL
: email address to be used publicly for contact purposes;BLOGSONIC_OUT_EMAIL
: the outgoing email (e.g.: sending the forgotten password email);BLOGSONIC_OUT_EMAIL_SMTP_PORT
BLOGSONIC_OUT_EMAIL_SMTP_HOST
BLOGSONIC_OUT_EMAIL_SMTP_USER
BLOGSONIC_OUT_EMAIL_SMTP_PASS
DB_HOST
DB_USER
DB_PASS
DB_NAME
If you want to, you can also run the acceptance tests made with Codeception. To do this, follow the next steps.
Note: If you decide to run the acceptance tests before actually using Blogsonic, you can skip the previous tables creation step.
Install Google Chrome and check its version.
$ google-chrome --version
Go to the ChromeDriver website and check which ChromeDriver version is the closest to your Google Chrome version.
Then:
$ wget https://chromedriver.storage.googleapis.com/<version>/chromedriver_linux64.zip
$ unzip chromedriver_linux64.zip
# mv chromedriver /usr/bin/chromedriver
From the blogsonic/
folder, run the following command:
$ bin/composer install
$ chromedriver --url-base=/wd/hub
$ vendor/bin/codecept run
You can also use the following command if you want to see all the single steps.
$ vendor/bin/codecept run --steps
Note: Running the acceptance tests will empty all the tables.
All tests are independent of each other. This means that you can run a single test (or a single suite) individually.
To run a single suite (found in the tests/acceptance/
folder), use:
$ vendor/bin/codecept run acceptance <name of the suite>
To run a single test from a suite, use:
$ vendor/bin/codecept run acceptance <name of the suite>::<name of the test>
For example:
$ vendor/bin/codecept run acceptance ProfilesCest
$ vendor/bin/codecept run acceptance ProfilesCest::register
For more information, see the official Codeception documentation.
Blogsonic is licensed under the terms of the Creative Commons Zero v1.0 Universal license.
For more information, see the Creative Commons website.