The framework I am working on right now is like a framework inside a framework which has a framework inside it, which turns out to be made up of other frameworks. I just can’t think of going deeper, afraid that i might never come out.
Your eyes close. Your imagination roams. An idea forms. You start typing furiously. Time passes without seeming to pass. Suddenly, a new product is born. Cue whiteboards, pitch meetings, investors. Launch! Your first customer. You hire your first employee. You … are a success. You … are an entrepreneur.
So we recently had this requirement to give ftp access to a third party client on our staging server. They did not want the hassle of sshing in and making changes or committing changes to git and then making the changes live. Now, installing an ftp with a username-password access might seem like a daunting task initially, but here is how I managed to do it.
Step 1 : Installing vsftpd server
vsftpd ( very secure ftp daemon ) is one of the popular ftp servers out there. After logging in to the ec2 instance, the following command will install vsftpd
sudo apt-get install vsftpd
Step 2 : Make the following changes to the vsftpd conf file
The configuration file can be opened up for editing at
sudo vim /etc/vsftpd/vsftpd.conf
And change/add the following flags:
pasv_address=[public dns from the amazon EC2 instance]
After doing the above, we need to boost up or daemon again.
sudo service vsftpd restart
Step 3 : Opening up port from the ec2 dashboard
Hop on to aws.amazon.com, login and go to your ec2 dashboard. Over there, for our particular instance, check the security group that it is a part of. Then hop on to that security group section and edit the rules of that particular security group as follows :
Notice that I’ve added the “All TCP” rule which will open up a range of ports for connection. Also note that we did not have a very strict security requirement, but if you are looking for that, then I would recommend opening up selective ports only.
Step 4 : Create a user and make him owner of the root directory
In the ec2 instance console, just add a new user by
sudo adduser ftpuser
It will prompt you to enter details including the password. After we are done with that, we need to make this user the owner of the directory which we want him to be able to read/write. In my case it was the document root for apache, hence the following command :
sudo chown -R ftpuser:ftpuser /var/www/html/
Yep, that’s about it. To login via FileZilla, the host needs to be the public dns of the ec2 instance; username and passswords will be the same as that of the newly created user. I took help from the following posts as a reference :
So, we recently upgraded our framework version from 2.2.3 to 3.0.0 at Seenit.in. The latest version is more around bug fixes and making the session library more secure. There is a huge debate these days over other frameworks, mostly Laravel vs CodeIgniter. Majority of the people are of the opinion that CI is now the granny PHP framework and we should be moving towards younger and better frameworks. But I’ve been a big fan of CodeIgniter from the beginning and don’t want to lose hope all that soon.
So after upgrading CI to 3.0, I decided to change some of my practices so that I gradually move towards a more modern style of coding. Here are some of my changes:
1. config_item() : This function was available in the previous version as well but I only found about it after upgrading. ( from the up-gradation steps ) I think it is a very handy shorthand for $this->config->item() function. Although the official user guide says that the latter is the preferred method over the earlier, but it also says that there is no harm in using it for retrieving single key values. So unless we are dealing with multiple config files with name conflicts, we should be fine.
2.  for array definition : This shorthand is pretty handy in my opinion. ( not exactly a 3.0 change ). Traditionally in documentations and online tutorials, arrays have been used using the array() syntax for both indexes and associative types. But in my opinion a
$temp = [ '1' => 'apple', 'two' => 'orange']
$arr = ['mumbai', 'delhi'];
are much more easier to type. The only limitation here is that this syntax was introduced in PHP 5.4. So as long as we are using a PHP with a higher version, we should be good.
3. $config[‘reuse_query_string’] = true : This new config value in the pagination library in 3.0 has been a huge help. So the way pagination links work in CI is that they append the offset to the url itself. So page 2 of the url http://abc.com/list will be http://abc.com/list/40 where 40 is the number of items you show on each page and url for page 3 will be http://abc.com/list/80 and so on. But if my page has some query params which I want to retain, like for the url : http://abc.com/list?q=php, the pagination url will ignore the GET params, like so : http://abc.com/list/40. But with the above config variable this is now possible. http://abc.com/list/40?q=php
So I’ve been trying to setup a Redis library inside CodeIgniter3.0. My first attempt was to search on git hub which landed me on joelcox’s repo. It seemed promising with enough number of commits and contributors, but as it said it has been deprecated, I had to look further. Now since Codeigniter also provides a Caching library out of the box, I decided to give it a try.
As illustrated in the documentation fairly well, to initiate the cache on needs to write :
The only difference is the additional array argument that I passed to driver() without which I was not able to get it to work. The redis config needs to be put in a file at location application/config/redis.php. Mine looks like this :
$config['socket_type'] = 'tcp'; //`tcp` or `unix`
$config['socket'] = '/var/run/redis.sock'; // in case of `unix` socket type
$config['host'] = '127.0.0.1';
$config['password'] = NULL;
$config['port'] = 6379;
$config['timeout'] = 0;
This is enough to get it to work, and for simple key value pairs the following two statements can be used to set and get the value :
$this->redisObj->save($key, $value, null); // save the data with infinite TTL
$this->redisObj->get($key); // get the value of the key
This is pretty handy. Although it does not provide more redis functionalities like increment or selecting all keys ( keys * ), it does the job for basic key setting/getting requirements. Looking further for a more feature rich Redis Library for CodeIgniter.
Just trying to setup a blog here.
Thankyou for visiting.