CakeDC Blog

TIPS, INSIGHTS AND THE LATEST FROM THE EXPERTS BEHIND CAKEPHP

CakePHP 3 Driver for Oracle Database

We are happy to announce and introduce the CakePHP 3 Driver for the Oracle Database (compatible with 11g, and 12 too). This plugin contains a fully operative Oracle 11g Driver for CakePHP 3. It's been a long awaited plugin due to the wide usage of Oracle systems in the business environment. The driver provides compatibility with various Oracle 11g and CakePHP functionality, including:

  • All the basic CRUD features to allow select/insert/update/delete rows.
  • CakePHP Pagination
  • CakePHP Bake code generation
  • CakePHP DebugKit specific tab
  • Autoincrement fields support (based on Sequence and Trigger)
  • Stored procedures and Packages (with different input and output params types including Cursors)
Code is released under MIT License here https://github.com/CakeDC/cakephp-oracle-driver Documentation available > CakePHP Oracle Database Driver We are also looking forward to introducing full migration support soon. Stay tuned for tutorials coming soon in CakeDC Blog!

The updates that CakePHP 3 brings to t...

  With a year under its belt and 34 releases, we are still in love with CakePHP 3; and some of you are already on board and loving it. With an average of nearly 3 releases a month, you can easily tell that the team is working against a rapid release cycle where they are tirelessly working at adding and improving features. - but do you know the philosophy behind it? Looking at all of the improvements and benefits that this updated framework brings, you can clearly see that the biggest turning point for the core team was the increased functionality with clear foresight and thinking brought to the table. A plan was had right from the start, to be a framework well documented, one that was simple (as the Core Team live by – less lines the better!). Another big input from the team, was the ability to integrate and make newer versions of PHP compatible with the framework, never before has the movement in the code base been so fast paced. And as the team comments, this is brought to the fore by the rotating code between open source teams – truly, we live in a space where without each other’s contributions to the code base there would be no movement and action. That is why we are in love with CakePHP 3, because the team have put forward a framework that integrates, pulls in outside assistance, accepts community help and specifically puts itself out there for the community’s input. Some quick backgrounds to the updated framework. The first commit to CakePHP 3 was done on May 24 2012, by Juan Basso. A long time coming, but as the common phrase goes, good things come with time. – that and the fact that the core team and lead developers were working in their spare time, after work, late nights, to bring this forward. We thought that we would reflect, and bring to you the top changes/improvements/benefits/total awesomeness of this framework!

  • All of the core feature development was done as pull requests. This was done intentionally, to encourage people to get involved and the main core team is distributed across the world. The community is vital to the framework, and without them, we wouldn’t be here!
  • To give you an idea of what this has meant. It ended up with over 6000 commits before launch! – from over 20 contributors.
  • CakePHP 3 documentation had over 1500 commits – from 51 contributors! – the document writing was so important to the team, every time there was a feature or a break in backwards compatibility, it was documented.
  • More big news for CakePHP 3 is that it targets PHP 5.5 and newer. It is designed with composer support (Although you don’t need to use composer). It has also required a couple of additional extensions (the mb_string and the intl extension) – this was for 2 reasons, we were handling multi-byte internally, if you didn’t have the mb_string extension, we would fall back to pure PHP code; and for internationalization - there are really powerful tools built into the language that CakePHP 2 wasn’t capitalizing on and the team wanted to leverage those tools – to give the CakePHP community better tools.
  • Now the entire CakePHP code is Unicode aware, and additionally through the intl extension, everything is localized. All of the core classes localize depending on your locale (so if you switch your locale to Germany..) – everything will work, your numbering, date formatting, language formatting (provided you have the translation file) etc.
Over above these changes (and associated benefits), a few other things came out of the cracks.. Such as, through the use of composer, you have to have separate repos for separate things - so the team created a new app skeleton, basically this is the app directory of the old framework but in a separate repo. – What this allows you to do is mold or easily customize and fork it when you want to pull in changes. You don’t have to worry about merge conflicts with the app directory or similar types of issues. It also gives us the ability to release them independently in the future, so for instance, the app can be upgraded and add or remove dependencies while having no need to modify the framework. Many of us have had that experience and confusion of configuring classes; you don’t know if it’s a property or method, or even what the method name is. Well getting more into the detailed features, we all know that there were a lot of different method names for configuring things, some classes used properties, others used methods of various names. For CakePHP 3 however, it was decided that this is a little silly, so all of the static/instance/runtime classes use one method called config (YAY!). More can be found at http://book.cakephp.org/3.0/en/development/configuration.html The ORM has also been replaced, we have moved on with the model layer, and CakePHP has advanced quite a bit over the past years. Now you have Tables and Entity objects (no more arrays!), and a powerful Query class to build your queries using a fluent interface. You'll be amazed how easy is to create deep filters, custom finders (and stacking!), subqueries. Validation was also refactored, improving flexibility and customization. The router was also noted as being a performance bottleneck for a lot of applications in the past, and it was also, somewhat, verbose when you were connecting a lot of routes. So with CakePHP 3, the old way of connecting routes is still there, but a new scope system has been added. This allows you to declare routes in a much clearer way – so if you have a common prefix, you can put this in the scope, and don’t have to re-declare this in each route. Less typing necessary, but more importantly it allows you to partition your routes so that you can create a much faster parse tree. A lot of work has also been done on fixing reverse routing, previously it was based on a linear search but now, the key parts of the route are taken (the action or controller name) and generate a list of what that route may be and then search a much smaller subset of routes. Another change is the helper layer. Previously HTML formatted through arrays, and that had both good and bad points. The team got rid of the sprintf and replaced it with a very simple templating system, that has no conditions. This lets you define templates file, and you consistently use those templates throughout. This also yields a bit of a performance gain and it doesn’t use number replacements, it uses named replacements. The way the event subsystems were handled is another change that CakePHP 3 brings to the table, allowing a much more consistent approach to handling events. The new changes have also led to another performance enhancement! The framework has also gotten some outside help - in the past CakePHP has been criticized for being insular and not making use of the existing ecosystem. This has since changed and one of the reasons was the team wanted to make the install really easy. Because composer is now being use, you can include dependencies and when you create your application or install your applications dependencies, CakePHP 3’s can be installed at the same time. CakePHP 3 has used: Chronos (A fork of Carbon) has been used for date time improvements, (but now its part of CakePHP itself and maintained by the core) Aura/Intl – improved i18n and L10n features A great wrap up to these things is the fact that the team has hugely increased functionality and features, while keeping performance constant (in most cases, actually increasing it!!). There are so many reasons that you should start and continue using CakePHP 3 but more importantly, there are so many reasons for being a part of this insanely great, collaborative community.

Cake Development Corporation - The ben...

  Cake Development Corporation was established in 2007 by Larry Masters, one of the founders of CakePHP. CakeDC provides professional development and consultancy services for a range of business needs, including startups, e-commerce and enterprise level corporations. Besides being experts behind the CakePHP framework, the team is backed by 50 years of combined experience. The team is highly talented, extremely approachable and work as a focused team when putting forward any piece of work. When the company was developed, the proposal was simple: to create a commercial entity that allows people to live and breathe CakePHP, doing what they love day-to-day, while also providing everyone with a means. Did we mention that we are based all over the world? Working remotely? – it’s one of the many benefits you sign into when working for CakeDC. We're an international team that offers commercial support and professional training for one of the most popular PHP frameworks used by developers around the world. But being based all over the world, we do look for key individuals to work with us. Some of the key aspects we look for in the ideal candidate include:

  • Good track history of Work Commitment and demonstrates good work ethic
  • Someone with full knowledge and/or experience of a full development cycle
  • Someone that demonstrates that they have good team spirit and takes initiatives
  • Ensuring they fulfill the qualifications outlined in the job post
For us at Cake Development Corporation, we feel that working remotely affords our employees a variety of benefits. Below are some of the main benefits from our team working remotely vs. being all centrally located.
  • With Remote employees we tend to have a lot more personal satisfaction which drives us to be independent.
  • Being based remotely, you obtain good results because the commitment is not pressuring for time, and being confined or distracted in a room with persons that may pose these issues.
  • We find that being a remote employee usually leads to being goal oriented and having the will to take the risk in working for as long as they want. Leaving the option be compensated for every hour of it and also doing exactly what they want.
  • Remote employees tend to be more productive as they are working in a conducive environment suited to their specific and individual needs.
At the Cake Development Corporation, we look out for employees who show
  • Discipline
  • Honesty and accountability
  • Ambitious
  • Focused
  • If Experienced, Demonstrate that experience
The distance doesn’t come in the way of getting to know our team or in the way of delivery impeccable work – with daily chats, catchups and integration tools, the team functions just like any other! CakeDC is on the forefront of modern organisations, recruiting top software developers and delivering top notch solutions to their clients! We are a dynamic company based on meritocracy, where everyone is given the opportunity to make an impact on the various levels and disciplines of the business, as well as playing a key role in the CakePHP community as the commercial entity behind the framework - the opportunity for growth is endless. And we haven’t even really gone into the real company benefits.. At CakeDC, everyone is appreciated, recognised and given the space and opportunity to grow. Some of our many benefits include:
  • 100% flexible work schedules, you are given the choice to define your hours of availability, 36 hours minimum required per week..
  • Remote working environment with an international team and clients.
  • The opportunity to Engage in paid open source projects, becoming an integral part of the development of the community. At CakeDC, all developers work 20% of their (paid development) time on open source projects.
  • Annual performance based bonuses.
  • Paid Parental Leave. Up to 16 weeks maternity leave and up to 6 weeks paternity leave, at 100% paid salary. Single fathers, or primary caregivers, can also take up to 16 weeks.
  • Available vacation time:
    • 10 days working days (not including weekends) per year. A minimum time of 12 months working at the company is required to take vacation.
    • 20 days working days (not including weekends) per year. A minimum time of 24 months working at the company is required to take vacation.
    • 30 working days (not including weekends) per year.A minimum time of 36 months working at the company is required to take vacation.
    • Christmas and New years are Company Paid Vacations.
  • Team outings and meetups – Don’t think that because this team is based internationally that we don’t know each other. We know the importance of getting together once in awhile, so we have annual meet ups!
  • A fully paid for IDE (PHPStorm) licence to assist you with our work and make your life a little easier.
So how do you know if you are right to apply to be a part of CakeDC? Well, if you aren’t shy, you know your stuff (Web application development, object orientated analysis and design, and of course, knowledge of CakePHP), are willing to put yourself out there and learn, and have a zest for life – then we are the right place for you!

CakePHP Facebook login using CakeDC Us...

The CakeDC Users Plugin provides an easy way to integrate Facebook social login into your application. Note this is the updated tutorial for the latest version of the plugin 3.1.5. This is a short how-to tutorial to enable Facebook login. We'll assume you have a brand new CakePHP 3.2+ application already setup.

Setup

Use composer to install the CakeDC Users Plugin composer require cakedc/users composer require league/oauth2-facebook:@stable Note we've upgraded to use league/oauth2 lib, and the old and not maintained opauth library was removed. Load it from your bootstrap.php file Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]); Run migrations to add 2 new tables: 'users' and 'social_accounts' bin/cake migrations migrate -p CakeDC/Users

Configuration

Load the Component in your src/Controller/AppController.php public function initialize() { parent::initialize(); // // ... // $this->loadComponent('CakeDC/Users.UsersAuth'); } login page output

Create a new Facebook application

  • Go to Facebook developers and log in
  • Create a new Facebook application new Facebook app
  • Click "website" and select some awesome name for your brand new app (yeah, some random name would work too)
  • Pick a Category, complete the quick start form, etc.
  • Once you are done, go to your newly created app and click "settings"
  • In settings, you should add your domain to "App domains" and ensure there is at least one login platform = "Website" defined
  • Copy your App ID and secret

Setup the Plugin to use your Facebook app for login

Now you have a working Facebook app configured, we are going to link the CakeDC Users Plugin to use the app for login. Update your bootstrap.php file to customize the CakeDC Users Plugin Configure::write('Users.config', ['users']); Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]); Create a new "config/users.php" file with contents return [ 'Users.Social.login' => true, 'OAuth.providers.facebook.options.clientId' => 'YOUR APP ID', 'OAuth.providers.facebook.options.clientSecret' => 'YOUR APP SECRET', //etc ]; This file will override any configuration key present in the Plugin, you can check the configuration options here Configuration. You are done! Now the "login with Facebook" link (in "/login" page) will open the Facebook login popup and connect back to your application. If the email is provided by the user, he'll be automatically registered using the default role = 'user'. If no email is provided, the user will be requested to enter an email to complete the registration process in your application. Once his email is validated (link sent via email), he'll be able to login using Facebook.

Read more about CakeDC Users Plugin

Giving back to the community

This Plugin's development has been sponsored by the Cake Development Corporation. Contact us if you are interested in:
  • Professional, commercial CakePHP development and consultancy
  • Professional CakePHP training
  • CakePHP code reviews
We hope you've enjoyed this short tutorial covering the Facebook login, stay tunned for new CakePHP + Users Plugin tutorials coming soon...  

CakeDC Users Plugin for CakePHP 3 - Up...

Welcome to our updated tutorial covering the new CakeDC Users Plugin for CakePHP 3. In this tutorial we'll setup and configure the Plugin, introducing some of the available features. Note this is the updated tutorial for the latest version of the plugin 3.1.5. We'll assume you are starting a new CakePHP 3.2.x application, with some existing tables (blog site maybe?).

Setup

Easy thing, let's use composer to install the CakeDC Users Plugin composer require cakedc/users Now ensure the Plugin is loaded from your bootstrap.php file Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]); Create some tables to store the users in your database bin/cake migrations migrate -p CakeDC/Users This migration will create 2 tables into your database, "users" where the users and credentials are stored, and "social_accounts" where the tokens for the social login feature will be stored and managed. Now you can register a new user (ensure your CakePHP is able to send emails to get your validation link correctly), or you could use the provided shell to create new users from the command line bin/cake users addSuperuser output for the shell command to generate new superuser This new super user will be granted full administrative permissions (check the src/Auth/SuperuserAuthorize class for more details and configuration)

Configuration

Load the Component in your src/Controller/AppController.php public function initialize() { parent::initialize(); // // ... // $this->loadComponent('CakeDC/Users.UsersAuth'); } login page output Now you have the Plugin installed and a brand new superuser granted with full permissions, it's time to configure permissions for the rest of the roles you'll need.

Simple role based permission rules

By default, the CakeDC Users Plugin allow users to register, and all new users are assigned role = 'user' by default. Note you can change the default role name assigned to new users, but we'll keep the 'user' role for now. Let's assume you have some controller with a couple actions you want to allow, for example "/posts/view/*" We are going to configure SimpleRBAC to allow the role = 'user' accessing the 'view' action: Create a new file "config/permissions.php" with the following contents return [ 'Users.SimpleRbac.permissions' => [ [ 'role' => 'user', 'controller' => 'Posts', 'action' => ['view'], ], ] ]; Now you've defined your first permission rule, allowing users with role = 'user' to access the /posts/view action, note you can use wildcards '*', and arrays to cofigure your rules. Cool, so now you have users in your application, allowing new users to register, validate their emails, login, change password, and use cookies to remember login. In our next short tutorial we'll cover Facebook login and Twitter login.

Ownership

What about ownership? We are talking about posts, and possibly you'll need to allow the post author to edit his own post, the good news: this is super easy with CakeDC Users Plugin. We'll assume you have a user_id column in your posts table to support the association Posts belongsTo Users. Add a new rule to allow only the owner of a given post to edit it. Update your permissions.php file, adding this rule: use Cake\ORM\TableRegistry; use CakeDC\Users\Auth\Rules\Owner; return [ 'Users.SimpleRbac.permissions' => [ [ 'role' => 'user', 'controller' => 'Posts', 'action' => ['view'], ], [ 'role' => 'user', 'controller' => 'Posts', 'action' => ['edit', 'delete'], 'allowed' => new Owner(), ], ] ]; And we're done, you've configured ownership permissions for your ['edit', 'delete'] actions. Check other examples in the CakeDC Users Plugin Docs

Read more about CakeDC Users Plugin

Giving back to the community

This Plugin's development has been sponsored by the Cake Development Corporation. Contact us if you are interested in: We'll continue working on our open source plugins (like this one) to give back to the amazing CakePHP Community!  

We Bake with CakePHP