Zend Skeleton Application A 404 error occurred Page not found - zend-framework

I'm new to ZF. I'm using wamp 3. I followed the instructions from the Zend Framework Documentation (https://framework.zend.com/manual/2.4/en/user-guide/database-and-models.html), installed ZendSkeletonApplication and everything worked fine until step 3 (routing and controllers) when I got the error:
"A 404 error occurred
Page not found.
The requested URL could not be matched by routing.
No Exception available".
I don't know what the problem is, since I copied everything from the tutorial on the site (so that I don't make any typo) and it still won't work.
Any suggestions what the problem might be?
module.config.php looks like this:
return array(
'controllers' => array(
'invokables' => array(
'Album\Controller\Album' => 'Album\Controller\AlbumController',
),
),
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
);
I did everything as they wrote, but when I go to "myvirtualhostname/album" it shows me the error above.

make sure you add this line (highlighted by comment) to the top of your public/index.php
<?php
use Zend\Mvc\Application;
use Zend\Stdlib\ArrayUtils; //<-- add this line
Note#1: you need to follow instructions of editing the index.php file for developing mode enabled, they just forgot to tell about using ArrayUtils in this tutorials.
Note#2 make sure to enable dev mod from the composer and dump autoload like this :
$ composer development-enable
and then:
[$ composer dump-autoload]

I believe you can specify the version you want to install with the initial composer command, something like this:
composer create-project -sdev zendframework/skeleton-application:^2.4 path/to/zf2-app
although you may be able to change the version on your existing skeleton app, it might be easier to run the above command in a different folder, and then copy over the files you've added or changed whilst following the tutorial.
And just to say again, unless you specifically need to learn ZF2.4, it would be better to stick with ZF3 (since that's the current version), and just follow the ZF3 tutorial instead. The differences between them are not that big.

Related

Zend Framework 3 share doctrine models between modules of the same project

I am new into Zend Framework 3 programming.
Previously we create a project having all database table's mapping included in one particulare module.
Now, we need to create another module into the same project. So we would like to put outside from the first module the database mapping objects in order to shared tha classes between the both modules.
I try to create a new module only for the mapping, but without succes. The namespaces doesn't existes.
After I look for solution like using ServiceManager, but I didn't really understand how to used it.
Do you know if there is another solution than using a ServiceManager ? And if not, have I change all my previous code using objects included simply with the key word use, in order to use the ServiceManager ?
Thanks.
Finaly in my solution I create a module containing only the sources files for the doctrine mapping under src directory.
/module
/MyApplication
/src
/config
/module.config.php
/Common
/src
/DoctrinMapping
/Entities
composer.json
In composer.json I put :
"autoload": {
"psr-4": {
"MyApplication\\": "module/MyApplication/src/"
,"Common\\":"module/Common/src/"
}
}
At the project root I execute the commande line :
composer dump-autoload
After into module.config.php of the my specifique application I define the doctrine reference as :
,'doctrine' =>
[
'driver' =>
[
'common_entities' =>
[
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver'
,'cache' => 'array'
,'paths' => array(__DIR__ . '/../../Common/src/DoctrineMapping/Entities')
],
'orm_default' =>
[
'drivers' =>
[
'Common\DoctrineMapping\Entities' => 'common_entities'
]
]
]
]
That works, but I don't know if this is the best solution to apply.

Invalid opus configuration for gstreamer

I'm struggling to figure out how to install opus plugin for gstreamer. I have installed
opus-tools & libopus0 by apt-get (everything happens on Ubuntu 14.04). I have also gstreamer-plugins-bad installed.
After multiple trials, bugs, etc. gstreamer displays the following error each time I try to call gst-inspect-1.0:
*(gst-plugin-scanner:17408): GStreamer-WARNING **: Failed to load plugin '/opt/gstreamer-1.4.0/lib/gstreamer-1.0/libgstopus.so': /opt/gstreamer-1.4.0/lib/gstreamer-1.0/libgstopus.so: undefined symbol: opus_multistream_encode*
What could have gone wrong during opus installation process that could cause this error?
If it's of any use here's result of ldd /opt/gstreamer-1.4.0/lib/libgstopus.so
*/opt/gstreamer-1.4.0/lib$ ldd /opt/gstreamer-1.4.0/lib/libgstopus.so
linux-vdso.so.1 => (0x00007fff859fe000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4f9004f000)
libgstaudio-1.0.so.0 => /opt/gstreamer-1.4.0/lib/libgstaudio-1.0.so.0 (0x00007f4f8fe08000)
libgsttag-1.0.so.0 => /opt/gstreamer-1.4.0/lib/libgsttag-1.0.so.0 (0x00007f4f8fbcf000)
libgstrtp-1.0.so.0 => /opt/gstreamer-1.4.0/lib/libgstrtp-1.0.so.0 (0x00007f4f8f9b5000)
libgstbase-1.0.so.0 => /opt/gstreamer-1.4.0/lib/libgstbase-1.0.so.0 (0x00007f4f8f75c000)
libgstreamer-1.0.so.0 => /opt/gstreamer-1.4.0/lib/libgstreamer-1.0.so.0 (0x00007f4f8f450000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f4f8f1ff000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f4f8eef7000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4f8ecd8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4f8e912000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f4f8e6f9000)
libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f4f8e4f4000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4f8e2f0000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f4f8e0e7000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f4f8dea9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4f90587000)*
I must have missed something when installing opus, however i've no more ideas what to do, so I'm counting someone can give me some hint where to look for, or what could have gone wrong?
Thanks for any help :)
your error means that opus library has not been correctly linked into your gstreamer.
Did you install gstreamer-plugins-bad yourself? while doing so, when you run the configuration script from the plugin-bad package, you could add following options:
./configure --host=xxxx --with-plugin=opus --prefix=xxxxx

What is the best way to versoining in install/ upgrade scripts?

Sometimes, I use any of the following mentioned names to name the install/upgrade scripts in custom modules:
install-0.1.0.0.php
upgrade-0.1.0.0-0.1.1.0.php
upgrade-0.1.1.0-0.1.2.0.php
----------------------------
install-0.1.0.php
upgrade-0.1.0.0-0.1.1.php
upgrade-0.1.1-0.1.2.php
Is there a standard way to follow for this naming conventions for install/upgrade scripts?
Versioning follows some conventions/standards, here is the code snippet from Mage.php to give an idea how module versions can be decided. This is for Magento version 1.7.0.2
array(
'major' => '1',
'minor' => '7',
'revision' => '0',
'patch' => '2',
'stability' => '',
'number' => '',
);
As I know, there's no standard way and you can name your scripts and versions as you need( it uses php version_compare anyway).

Zend_Form - The mimetype of file 'foto.jpg' could not be detected

I have a Zend_Form with file element like this:
->addElement('file', 'image', array(
'required' => false,
'label' => 'Venue Image',
'validators' => array(
array('IsImage', false),
array('Size', false, '2097152'),
array('Upload', false),
),
))
And when I'm using localhost the image is uploaded successfully. But when I move to my hosting the validation error shows for image field. The mimetype of file 'foto.jpg' could not be detected. What can be the reason of this?
same thing happened to me, this was crazy stuff, more than 2 hours trying to figure out what's wrong, here is how to fix it:
install fileinfo extension on linux:
pecl install fileinfo
then you need to add to your php.ini this line:
extension=fileinfo.so
restart your apache and you are done!
*if you server is freeBSD you have to do this:
cd /usr/ports/sysutils/pecl-fileinfo/
make install
If you are using XAMPP and localhost just open your php.ini file and uncomment:
extension=php_fileinfo.dll
From the comments in the ZF Reference Guide:
In order to make IsImage working (and maybe all other mime related validators) on Zend Server on win32 I had to replace "magic.mime" supplied on Zend Server ("\etc") by the one on Apache ("\conf" , file is called "magic") (don't forget to restart Apache).
If it still doesn't work then you could try with these alternatives:
$element->addValidator('Mimetype', false, 'image/jpg');
or
$element->addValidator('Extension', false, 'jpg');

zend_db query on connect

I want the query 'SET NAMES utf8' to execute before any other queries.
But, if I execute it in the beginning of my app, it forces Zend_Db to connect to the Database, even if I'm not running any other queries. It isn't cool: My app processes lots of requests without any queries, only using cache.
How to ask Zend_Db to run 'SET NAMES utf8' right after connection?
Sure, simply pass the 'charset' option in with the adapter params. You can do this via Zend_Config or in code:
$params = array(
'host' => '127.0.0.1',
'username' => 'webuser',
'password' => 'xxxxxxxx',
'dbname' => 'test',
'charset' => 'utf8'
);
$db = Zend_Db::factory('Pdo_Mysql', $params);
Reference: http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.connecting.parameters
check this link for config option , its more easier
How to make PDO run SET NAMES utf8 each time I connect, In ZendFramework.