Posts

Showing posts from February, 2013

creating stick stylish button using css3

CSS3 is rapidly expanding the toolkit that web developers and designers have to make visually appealing components without the use of images, Photoshop, or CSS sprites. While all of those have their place, and will never be completely removed from the development process, buttons are one component of a website that we can make dynamic, slick and scalable – exclusively in code. All of the CSS3 buttons that we create today will be styled forms of anchor tags. Some like to use button elements for these, but I find it’s easiest to use anchor tags so you can easily add the :hover and :active pseudo classes and quickly add href to it to complete the button. What We're Creating For this tutorial, we’ll be creating several different CSS3 buttons, all of which can have different colors, shadows, sizes – all using pure CSS3. We will be using the following properties: border-radius , linear-gradient , box-shadow , text-shadow and opacity . you might want to change some of these

Controllers as Services in Symfony2

Controller as a service is continually touted as the best practice. But why would I wrap a controller into a service? That's good question. Well, the point of doing this in general is not having to inject the DI container into your controllers (instead, you inject the dependencies into the controller directly). Thus the controller no longer depends on the container. Good: You get added flexibility. You no longer hard-code which services to use into your controller. You can specify that in the DI configuration instead. Example: You inject a UserProvider into the UserController for /profile, but inject a FacebookUserProvider into the same UserController for /profile/facebook. Bad: You must manually configure your dependencies in the DIC config. You need to manually assign the injected dependencies. Optional dependencies are no longer lazy-loaded. This is basically just a proof of concept to show how it could be done. namespace Acme\DemoBundle\Controller; class FooContr

run symfony command from controller

Hi Friends, Few month back I was trying to execute Symfony2 command in my controller. See how can we do that. Step 1 Register you command as service MyCommandService: class: MyBundle\Command\MyCommand calls: - [setContainer, ["@service_container"] ] Step 2 In your controller, you'll just have to get this service, and call the execute method with the rights arguments. Set the input with setArgument method: use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Output\ConsoleOutput; . . . public function myAction() { $command = $this->get('MyCommandService'); $input = new ArgvInput(array('arg1'=> 'value')); $output = new ConsoleOutput(); $command->run($input, $output); } Step 3 Either you can use the execute method of command: $command->execute($input, $ouput); But see the defination of run() and execute() methods. run () -: The code to

protecting php file with ionCube encoder

One of the issues PHP developers face is that PHP is an interpreted language, meaning PHP source code is readable by anybody who downloads your applications. In this article I will show you how to protect your intellectual property by encoding your PHP source code. The tool we are going to use to protect our code is ionCube PHP Encoder . Before releasing your PHP software, you use the encoder to convert your plain-text PHP files into special encrypted files. While ionCube PHP Encoder is a commercial product, there is a time-limited trial available for download . Because your PHP is encoded into a special byte-code (as opposed to just being obfuscated), a loader must be installed on your web server. A loader is a PHP module that must be installed. Fortunately, ionCube PHP Encoder is commonly used and therefore many web hosts will already have a loader installed. On the ionCube website there is a loaders page which contains the latest versions of the loader for all supported plat

multiple cron job using same file

Hi guys, Today I am posting something about cron. 1 year back, I was getting some trouble in my project in scheduling cron. I had lots of task to be managed by cron, for that I was making multiple files. But after some research I managed those task by a single file. If your cron job accomplish similar tasks or requires the same libraries you will have to include the same files over and over to all your cronjobs ... or use this solution. Let say you have these cron jobs: 0 1 * * * /etc/lib/php -q /home/user/cron/cron1.php 15 1 * * * /etc/lib/php -q /home/user/cron/cron2.php 30 1 * * * /etc/lib/php -q /home/user/cron/cron3.php 0 2 * * * /etc/lib/php -q /home/user/cron/cron4.php And each of these cron jobs perform different tasks but use the same libraries like phpmailer, pdf creator, geoip, payment verification etc... The idea is simple, separate tasks or commands using parameters: 0 1 * * * /etc/lib/php -q /home/user/cron/cron1.php --task=task1 15 1 * * * /etc/lib

connect to multiple database from drupal

Drupal has the ability to connect to multiple databases, allowing you to use Drupal’s built in database abstraction layer on more than just Drupal's primary database. Preferably you would add your configuration in the settings.php file for your site, so that all modules can interact with the new database. Drupal 7 In your settings.php: $databases = array(); $databases['default']['default'] = array( // Drupal's default credentials here. // This is where the Drupal core will store it's data. ); $databases['alternate_db']['default'] = array( // Your secondary database's credentials here. // You will be able to explicitly connect to this database from your modules. ); The way to use it in module: // Use the database we set up earlier db_set_active('alternate_db'); // Run some queries, process some data db_query('...............'); //Switch back to the default connection when finished. // other

create and execute a command in symfony 2

In Symfony 1.x a task is a command line tool to help perform tasks around the application. The same is in Symfony 2. Unfortunately in Symfony2 there is no tool to auto-generate some code for these. To create a Symfony2 Command you must to have or to create in your Bundle a folder named Command. Symfony 2 is mainly used to create web application, however, sometimes you need to extend your app and need a command line tool to help perform tasks around the application. It's one of the most stable parts of the framework and many people have already been using it for several months in many projects as it makes it really easy to develop this kind of software. And of course, everything is done in a really cool way, as many of the parts of Symfony2. Let’s see how can extremely easy create a new Command Task and custom our output. Create a file in Command Folder, for instance NewsletterCommand.php and fill it with an empty Command structure as follows <?php namespace Ankit\News

how to use claim token in technorati

It's very easy to verify your blog using claim token in technorati. although technorati doesn’t show you how to claim your token to verify your blog in technorati. Here I’m going to tell you how to verify your blog listing in technorati using claim token. after creating an account in technorati, you recieve a mail having the text following from them. This is an automatically-generated email. Thank you for submitting your blog claim on Technorati . Technorati will need to verify that you are an author of the site http://ankitchauhan22. blogspot.in by looking for a unique code. We have just assigned the claim token ############## to this claim. Please visit http:// technorati .com/account/ for more details, including how to use the claim token. Follow these steps to verify your blog using claim token. Create a new post (such as this) using your blog panel. Copy the claim code from your email. Paste your 12-digit technorati claim token in the body of the post.