In our project we don't need a database, so how do we setup cakephp 3.x on a local machine without modifying the database config? I have this issue when I'm running my site.
Error: Class 'PDO' not found
File /usr/share/nginx/dchannel/vendor/cakephp/cakephp/src/Database/Type.php
Line: 100
So please suggest a better way to do disable the database on cakephp 3.x
Thank you in advance.
Theoretically that should be possible if you just avoid to touch anything that interacts with the datbase, or uses PDO related constants and stuff, like the Type classes that are by default involved in the applications bootstrap:
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L174-L189
Also you cannot use Migrations or DebugKit, as both require PDO:
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L206-L207
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L211-L217
If you comment these snippets, and do not touch the model layer anywhere, then it should work. However I don't think that there is a guarantee that this will continue to work. If you want to make sure you can ask the core devs over at Slack or IRC, or maybe even open a ticket on GitHub.
I think it is possible because cakephp use its own design template. so just replace the template with your one .
php default template \src\Template\Pages\home.ctp
I don't think it's possible to set up CakePHP without a database; it is basically a frontend to a database so the tool doesn't work without one, and I think it also uses it to store some of its configuration. If you don't need a database, then I advise you choose a different framework.
Related
I am working on a plugin in CakePHP3 and I need to create a simply Oauth 2.0 Server API that allows to do a simple CRUD on the users' table and create sessions when needed.
I have done some research here in StackOverflow and it seems that the best choice would be
https://github.com/uafrica/oauth-server
Now, I have tried to make it work according to the doc in the repository but since it will be a plugin, not the core of the application I do not understand how it is supposed to work and which file I need to update.
Would somebody be so kind to give me the list of steps I need to follow and the actual files that need to be updated?
Many Thanks in advance
The uafrica/oauth-server project is woefully out of date. It requires v4.1 of league/oauth2-server, which is now currently at v7.2. Version 5 of that project was completely rewritten and is not backwards compatible with v4.x.
I don't think there's an out-of-the-box CakePHP 3 plugin that works with the current version of league/oauth2-server.
You'll have to either build your own plugin from scratch, or try to hack the uafrica/oauth-server project to get it work with league/oauth2-server.
I'm trying to access the controller from another CodeIgniter.
I have a CodeIgniter 3.0.4 that containing:
Application
codeigniter2
css
js
...
so I have already tried $this->load->library('../controllers/home'); ,
but it shows me the Unable to load the requested class: Home
And I'm trying to login to both at the same time so I need to access each Session
I would strongly suggest that you simply either import the required library or combine both apps into the latest CI 3.1 as there have been several security fixes plus many more bug fixes. Upgrading from 2.x to 3.x is usually a very simple task.
However, you will not be able to use the CI loader to load a controller or library outside the normal directories, and you will not be able to share sessions across them either, as both sessions will have a different format for their session tables.
At a push, you might be able to create a bridge library, that includes the files you want, from the older CI version, but to be honest, unless the libraries you are connecting to are completely empty of any CI references, more like functional helpers rather than libraries, it just is not going to work, or would take far more work to achieve that it would to just upgrade and combine your old system. The advantages of doing that far outweigh the problems you are going to face with a bridging mechanism.
Sorry if that is not a lot of help, but in short, combine them into one app and upgrade to the latest version ASAP.
Best wishes,
Paul.
I have a database we use on some of our existing websites, sites were built in Yii framework by another developer so no Laravel, I have set up a new project using laravel but am looking for the best way to link up to that database and return the information.
linking to the database is easy enough, just change the database.php file but I am getting really confused with migrations part and how to call it into a webpage.
So what's the simplest way to go about doing this?
Migrations are used to create or modify database structure. Since you already have a database set up, you don't need to use migrations.
To get accustomed with Laravel I strongly suggest watching:
Laracasts - Laravel 5 Fundamentals
I also suggest you go over the entire Laravel Documentation just to get acquainted with all the framework has to offer.
I'm looking for a good php framework with support for handling database migrations. Ideally I would like to be able to run a command that generates a migration script, one that updates the database with changes and can handle rolling back those changes. Is there anything out there that does this?
The Doctrine project supports migrations - http://www.doctrine-project.org/projects/migrations/2.0/docs/reference/introduction/en
Hmm, that documentation is a bit lacking, at least in the introduction. Hopefully it gets better as it goes on.
Whilst most popular in Symfony, this can easily be integrated into other frameworks or even used on its own.
Promising, but not yet have a stable version : https://github.com/fuel/fuel
There is a new php framework called Laravel and it has migrations the same way as ruby on rails. It seems so pretty!
You can find it at http://laravel.com/
Migrations Docs
In addition, the framework introduces the idea of bundles, what can give to your project a great modular view.
If you try it, tell us your experience! :)
symfony - http://www.symfony-project.org/
In symfony you can write database schema using ORM like Propel, it is independant from database driver. If you have a database already, you want to migrate to a different db, I think you can dump the db, change the db config, and re-import it to the new db. (though I have not tried it myself.)
There are much php framework over there that can use any database. For example Zend, Ci, Cake and many others. One thing you should do is change database type that's usually stored in configuration file. And then migrate your database manually. No framework that can generate migration script automatically. U can also use ESF for database migration
I'm starting to familiarize myself with using the module-based architecture for zend framework projects. My real reason behind being interested in the module architecture is to be able to take a module from one project and just drop it into another project. Maybe I'm not getting it right..
But what I'm noticing right off the bat is that controllers within each module cannot have the same name as any other controller in the main application (or in any other module, though I haven't tested this). This leads me to think that modules are not really independent self-contained units, so I wonder how this affects their ease of distribution from one project to another.
The other issue is what if I were to take a module and drop it into another project. Do I have to update the .zfproject.xml manually? and wouldn't that be a bit too cumbersome to be done manually?
Maybe I'm not clear on how modules should be used in zend, so I'd like to know when you decide it's best to use them, and when do you decide not to use them, or do you use them all the time, or do you never use them?
I always used module based architecture so far in my projects, because I like to separate concepts. For example I have always an ADMIN module whose classes and controllers dont mix with the rest of the application. Using modules you can reuse modules for other applications, for example if you create a BLOG module.
The names of your controllers will be something like Admin_IndexController for the admin module even if the file is named IndexController.php.
Another concept that is nice and help you reuse resources is the plugins. Use them for authentication or to check validity of the requests.
You need to setup namespaces for your modules so that they are easily moved into a new project without renaming.
If you are using Zend Tool then you will have to edit the zfproject.xml. I haven't spent a lot of time using this so I'm not sure if there is another way without manually editing.