Automatic DB setup for CakePHP plugins - php

Let me disclaim first, that I'm a total CakePHP newbie. I am pretty proficient in PHP and MySQL however, having developed my own frameworks, etc., until I saw that other frameworks have already done the work for you :/ I'm trying to get into CakePHP cuz it has great documentation, good organization and the powerful console.
I've gone through the basics now and am trying to look into plugins - I have decided to start with the comments plugin, found at: http://cakedc.com/eng/downloads/view/cakephp_comments_plugin
I followed the first few lines of instructions to where I'm supposed to see the thing work, but it gave me errors about missing tables (e.g. Database table comments for model Comment was not found.). Certain I'll find a file, I've found this: /app/plugins/comments/config/schema/schema.php. The $comments array looks like it's formatted to be automated, instead of creating tables manually. But googling has failed to produce a good guide.
What line of instruction am I missing? Is there a way to use the console to convert this array (and other schema the plugin may require) into the DB scheme? Is there a script I should run every time I install a plugin?
Thanks in advance for your help.

You load the schema via the cake shell. More info here: h
http://book.cakephp.org/view/1524/Generating-and-using-Schema-files

Related

Dynamically add or remove code module in a laravel project

I have been trying to understand how this concept works. Adding or removing code modules from laravel project. I have seen this feature in many places such as quickadminpanel.com, October CMS etc. These sites are used to create an admin panel quicker, there is an interesting feature that i found in quickadminpanel that is installing module that i need. Basically i want to achieve this but i don't know how to do !! May be someone can help as this feature and concept actually exists.
The author himself replied in a mail. Now the concept is much clear to me. He simply replied this, "It's similar to how Laravel works with stubs - copy-pasting files as templates, replacing the variables in content: youtube.com/watch?v=eWarTZuates&t=1s"

Where can I share my benchmark results for elasticsearch php vendors

I've benchmarked several elasticsearch php vendors, and I would like to share my experience!
I would write a simple topic on some blog (or something else) related to elasticsearch or php.
Could someone please advise me where I can post such info?
Create a repository on Github and push your test setup and a php shell to run the benchmark. Don't forget to add a meaningful readm.md.
Oh and, give me the URL of the repo, I would like to run them as well. :) I'm pretty sure other people have an interest in this as well.
"Medium" is quite nice for such purposes.

How to bootstrap/setup Angular2 in an existing Laravel project?

I am looking to implement Angular2 inside my current Laravel project. I've read about many setups including AngularClass's version with Webpack, but I feel like it's all over-complicated.
What I wish to make:
A simple single page app inside my Laravel app.
It needs to have something like Grunt/Gulp or even Webpack to compile upon changes.
Does not need NodeJs to run in production, no lite-server, just like AngularJS it can be injected and that's it.
I need to understand the implementation files to achieve this, so no starterpack or angular-cli, unless if you can supply good arguments.
Looking for a "how to"-like example on creating the above.
Thanks in advance.
EDIT: More information
As ANKH pointed out, i needed a more detailed and coursed question. So here we go:
- Looking for a example implementation of a Angular2 based SPA inside an existing PHP application (Laravel).
- I've tried many different tutorials, going from the heroes tour, to Sitepoint and AngularCLI based tutorials, but they all assume a SPA on it's own. Ergo, they are compiled and served through NodeJS, which I don't need.
Turns out that I've actually been looking at this entirely wrong. I've gone with using Angular-cli and found that I could generate the output files and include these inside my Laravel project. No need to integrate them further.

PhpBB's automod like software for php

I have looked and looked all over to find a way to make something similar to PhpBB's automod system they use for their software.
I cannot seem to find anything similar to this with the whole xml find and replace code updater and mod installer.
I may just be typing in the wrong keywords in Google, but does anyone know of any system like this available before I start trying to make my own?
EDIT: I mean more like a code updater. For example find and replaces in a php file.
FIND:
?>
ADD BEFORE:
echo "this is text added before the ?>";
I realize this could be done with str_replace but there is surely a system out there that already does this reliably.
The reason that a system doesn't exist outside of phpBB is because it's an incredibly poor way to manage modifications. Your question does not make it clear what you want to gain from this, but since it is your own code, you should definitely not look to copy something so awful.
For “patching” code
If you want the ability to apply updates to your code, then you should look at handling it through version control. For instance, you could develop and test in a local git repository, and once you are happy, push the changes to the server. You have many options here from a basic update script to a fully-fledged Continuous Integration solution.
phpBB have implemented a solution for patching code on your live site via a Web interface, which has many issues with security, verifiability and maintainability among others.
For exposing “plugin” functionality
If you want the ability to register plugins in parts of your code, then you should architect your code as such to allow it to be handled easily. Wordpress, MediaWiki and other projects can help you write such a structure.

How do you find the block of code you are looking for in Magento?

I have been struggling with a stupid situation. A customer has asked me to alter his 'advanced search' page to add a few options. The URL of this page is like http://www.domainname.com/index.php/catalogsearch/advanced/
This is a Magento store and I have no experience with this framework. I tried to learn it but found the learning curve too steep to gain enough knowledge to finish the project on-time.
So I first made a small PHP tool that searches in all source files for a search term and reports back te number of hits. I used this tool to look for unique strings that appear on the advanced search page. But the text is nowhere to be found!
My next attempt was looking at the database to find the string. So I exported all DB data and copied the resulting queries into my code editor and searched again, and found nothing!
This is very awkward and is driving me mad. I cannot find the block of code that outputs the advanced search options!
'ANY' help would be MUCH appreciated.
Thanks,
Majid
So far I've been using the following tactics on a local dev box - don't try this on a live store obviously!:
Turn on Template Path Hints + Block Names in System -> Config -> Developer. This will get you to the phtml file that does the final render and also the block object type that it uses. Unless you've IP limited this, every visitor will see these!
Then in the phtml files to dig further you can easily Zend_Debug::dump($var) to inspect the variable/object in question and find the object type etc.
Search in your editor or grep through /app/code directories to find which files define the object type you've just found - although as it based on Zend the correct file path can be worked out most of the time from the object class.
Also
A handy trick is to deliberately insert an error in a php/phtml file, Magento gives you a nicely formatted error screen with a call stack which is interesting reading
echo() statements in the core files normally work pretty well, in the Magento set up they don't normally trigger the html headers to be sent at the wrong time
Use an IDE like Netbeans/Eclipse/Zend studio etc and put all the Magento code into your project, the resulting phpdoc information, 'open declaration' and code assist will save you hours of searching
Spend the time to get Xdebug working on your test server with an IDE that allows you to make use of it. The easiest one I've found to setup from scratch (on a Mac) is a local Mamp install with Netbeans as the IDE - the Netbeans site will walk you through this, once you've got this working well you can forget about most of the other tricks!
These are just the things I've tried so far - more suggestions please!
I've still not found a technique to debug config problems from XML issues in the multitude of XML files that Magento uses, problems here tend to fail silently and are really hard to track down as a result + the xml documentation is awful.
The URLs in Magento tell you where the template files are for a certain module.
For example, when you're looking for catalogsearch/advanced/, all template files are location in app/design/frontend/default/your-theme/.
Look inside that folder and it should be obvious. You will have a folder called catalogsearch and inside that a folder called advanced; inside which there are two files:
form.phtml
result.phtml

Categories