Application_Model_Classname not found in Zend framework - sql-server

I am using following directory structure in Wamp server and i am getting an error Fatal error: Class 'Application_Model_ClassName' not found:
www--->pnp--->client--->application
--->controllers
--->modules
--->models
--->docs
--->library
--->public
--->.htaccess
--->.buildpath
But when i remove client directory from the above structure its working fine. With the following structure its working fine.
www--->pnp--->application
--->controllers
--->modules
--->models
--->docs
--->library
--->public
--->.htaccess
--->.buildpath
Please suggest, so that i can use client or dev or qa directory.

We need to autoload model files in the the Bootstrap.php, with the following code.
protected function _initAutoLoad ()
{
$autoLoader = Zend_Loader_Autoloader::getInstance();
$resourceLoader = new Zend_Loader_Autoloader_Resource(
array('basePath' => APPLICATION_PATH, 'namespace' => 'Application',
'resourceTypes' => array(
'form' => array('path' => 'forms/', 'namespace' => 'Form'),
'model' => array('path' => 'models/', 'namespace' => 'Model'))));
return $autoLoader;
}

Related

laravel uploading image in database with wrong path

Uploading a images to the database give the wrong path.
It should referense to my storage/uploads directory
Also i have done this command to make the storage folder public.
php artisan storage:link
enctype
enctype="multipart/form-data"
My code:
public function store(Posts $posts){
$validation = request()->validate([
'name' => 'required',
'ingredients' => 'required',
'prepartion' => 'required',
'categorie_id' => 'required',
'image' => 'required|file|image|max:5000'
]);
Posts::create($validation);
$posts->update([
'image' => request()->image->store('uploads', 'public')
]);
return redirect('/admin');
}
If more info is needed please let me know
You should have to you Storage Facade and use disk which should defined in config/filesystem.php to store image.
Storage::disk('public')->put($path, $content);
You may call the putFile method on the Storage facade to perform the same file manipulation
$posts->update([
'image' => \Storage::putFile('uploads', request()->file('image'));
]);

Drupal hook not being called

I'm new to Drupal making a plugin that hooks into the ckeditor widget. I absolutely can't figure out why my implementation of a hook that is defined in ckeditor is never called.
Here are some details
my module is enabled
I'm able to use more basic hooks like exceltohtml_plugin instead of exceltohtml_ckeditor_plugin and reach my test statement.
I'm can't think of any more troubleshooting ideas to reveal the issue so any help would be greatly appreciated.
exceltohtml.module
<?php
error_log("TEST: this will print to log");
// implementation of hook_ckeditor_plugin()
function exceltohtml_ckeditor_plugin()
{
error_log("TEST: but this will never run");
return array(
'exceltohtml' => array(
'name' => 'exceltohtml',
'desc' => t('Excel sheet upload'),
'path' => drupal_get_path('module', 'exceltohtml') .'/plugins/exceltohtml',
'buttons' => array(
'excel_to_html' => array('label' => 'Insert spoiler','icon' => '/images/image.gif' ),
)
)
);
}
ckeditor.api.php (the file in ckeditor that Im basing my hook on)
/**
* Hook to register the CKEditor plugin
*/
function hook_ckeditor_plugin() {
return array(
'plugin_name' => array(
// Name of the plugin used to write it.
'name' => 'plugin_name',
// Description of the plugin - it would be displayed in the plugins management section of profile settings.
'desc' => t('Plugin description'),
// The full path to the CKEditor plugins directory, with the trailing slash.
'path' => drupal_get_path('module', 'my_module') . '/plugin_dir/',
'buttons' => array(
'button_name' => array(
'icon' => 'path to button icon',
'label' => 'Button Label',
)
)
)
);
}
If the function in your module is new, then the slightly older version of your module code might be cached.
Visit the module listing page in Drupal, that should reload the modules PHP code:
admin/modules

How can I create cached files within CakePHP Plugin?

I have created a plugin for CakePHP that I would like to generate cached files within its own plugin folder at /app/Plugin/MyPlugin/tmp/cache.
I have already cerated the MyPlugin/tmp/cache directory manually.
I have created a bootstrap file at /app/Plugin/MyPlugin/Config/bootstrap.php with the following content:
<?php
Cache::config('short', array(
'engine' => 'File',
'duration' => '+60 minutes',
'path' => 'Plugin/MyPlugin/tmp/cache',
'prefix' => 'cake_short_',
'mask' => 0666,
));
I have created a Shell script at /app/Plugin/MyPlugin/Console/Command/MyPluginShell.php with the following function:
<?php
...
public function get_listings() {
$listings = $this->Listing->find('all');
Cache::write('listings', $listings, 'short');
$this->out('Task Completed');
}
I can run get_listings from within the Cake console just fine and the Task completes, however there is no Cache file being created at /app/Plugin/MyPlugin/tmp/cache like I would expect.
On a side note, I have tried replacing 'path' => 'Plugin/MyPlugin/tmp/cache' with 'path' => CACHE just to see if it will appear in app/tmp/cache but haven't had any luck.
I have also created the /app/Plugin/MyPlugin/tmp/cache within the plugin.
Any help would be appreciated.
I figured it out.
I wasn't loading the plugin correctly within app/Config/bootstrap.php.
I was doing this (incorrect):
CakePlugin::load('MyPlugin', array('routes' => true));
Instead of this (correct):
CakePlugin::load('MyPlugin', array('routes' => true, 'bootstrap' => true));

Error Loading Views After Changing Route Value of module.config.php - Zend Framework

This question is regarding Zend Framework application version: 2.1.3. I, the developer, am new to Zend Framework and would greatly value your assistance.
I was making a module for a 'Donor Management System' of a church. The module I am working on is called the 'QueryBuilder'. Previous modules were fine and works great. I use the Zend Helper for Sublime Text and it generated some thing similar for the module.config.php
<?php
/**
*
* #package QueryBuilder
*/
return array(
'controllers' => array(
'invokables' => array(
'QueryBuilder\Controller\QueryBuilder' => 'QueryBuilder\Controller\QueryBuilderController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'querybuilder' => array(
'type' => 'segment',
'options' => array(
'route' => '/querybuilder[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'QueryBuilder\Controller\QueryBuilder',
'action' => 'index',
//'action' => 'search',
//'action' => 'recent',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'querybuilder' => __DIR__ . '/../view',
),
),
);
?>
Determined to have a little bit of fun after making some successful modules, I changed the router as follows.
<?php
/**
*
* #package QueryBuilder
*/
return array(
'controllers' => array(
'invokables' => array(
'QueryBuilder\Controller\QueryBuilder' => 'QueryBuilder\Controller\QueryBuilderController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'querybuilder' => array(
'type' => 'segment',
'options' => array(
'route' => '/query-builder[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'QueryBuilder\Controller\QueryBuilder',
'action' => 'index',
//'action' => 'search',
//'action' => 'recent',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'querybuilder' => __DIR__ . '/../view',
),
),
);
?>
Note: Only the route value was changed from /querybuilder... to /query-builder.... When I tried to access the route http://konnections/query-builder I got some error but I didn't go through it.
Wondering why I wan't to be a hero, I changed the value back to its defaults. And tried to load http://konnections/querybuilder but it also gave an error.
Zend\View\Renderer\PhpRenderer::render: Unable to render template "query-builder/query-builder/index"; resolver could not resolve to a file
No where in the code of the module you could find the words query-builder. So common sense says there can be no way query-builder/query-builder/index needs to be accessed.
Thinking it might be some caching, I looked for it in the entire application folder. Then I restarted Apache, the computer, deleted and made a new Module with the same name QueryBuilder and still the error is there.
Note: This is a plugin that was done nothing with. I only changed the route value thinking it will make the URL look neater.
Here is what I end up with [Image]:
Nope, this is not IE, because I tried in Chrome (which didn't access the query-builder url) as well.
The whole of Zend Folder (the root of the website) has no reference to query-builder. Where does it come from and how can I change it?
Thanks in advance.
from ZF1 series (http://framework.zend.com/manual/1.12/en/zend.controller.basics.html), ZF2 is the same but not found this description on manual.
Case Naming Conventions
Since humans are notoriously inconsistent at maintaining case sensitivity when typing links, Zend Framework actually normalizes path information to lowercase. This, of course, will affect how you name your controller and actions... or refer to them in links.
If you wish to have your controller class or action method name have multiple MixedCasedWords or camelCasedWords, you will need to separate those words on the url with either a '-' or '.' (though you can configure the character used).
As an example, if you were going to the action in FooBarController::bazBatAction(), you'd refer to it on the url as /foo-bar/baz-bat or /foo.bar/baz.bat.
I am Ziyan, the one who asked the question in the first place.
After not finding a solution in Google, I wondered in to making another module and ended up with the same plight. Confused I made a new installation of Zend Framework and made a module with the same name.
Zend\View\Renderer\PhpRenderer::render: Unable to render template "query-builder/query-builder/index"; resolver could not resolve to a file did not go away.
Knowing it is not some thing like reconfiguration, I looked closer.
It seemed to put a dash between every word. I was like Zend is insane! But no, it seems to be splitting the Module name from each upper case letter and adjoining them using a '-' (dash).
In my case QueryBuilder becomes query-builder or plugin named HelloModules would be hello-modules.
So the view manager seems to be looking for ../views/query-builder/query-builder/index.
In my case, ZF Helper for Sublime text needs to look in to the situation. If you could fix the plugin at GitHub it would be great. I will give a try my self.
I couldn't find any proof for my claiming and no time to go through the source codes. Would be glad if some one provide some links.

Vagrant + Chef Solo not using Apache attributes

I'm trying to provision a CentOS box using Vagrant and Chef Solo. I've specified some attributes I would like the apache2 cookbook to use but it does not appear to be using them.
Here's what I've added in my Vagrantfile:
chef.json.merge!(
'apache2' => {
'user' => 'testuser',
'group' => 'testgroup',
'dir' => '/custom',
'log_dir' => '/custom/logs/http',
'default_site_enabled' => false
}
)
chef.add_recipe "apache2"
Yet, after running vagrant up the apache cookbook has ignored all of the attributes I've specified. I've tried using both apache and apache2 as the key.
Am I missing something simple? Thanks!
This should merge the attributes into the node.
chef.json = {
'apache2' => {
'user' => 'testuser',
'group' => 'testgroup',
'dir' => '/custom',
'log_dir' => '/custom/logs/http',
'default_site_enabled' => false
}
}
And this is how you would access it.
node['apache2']['user'] # => testuser

Resources