1
I created my API with Apigility, made the deploy and everything was working fine until I uploaded the files to my server (hosting). Once I uploaded the files and acceded to the Apigility project Uta on my server I found the following error:
404 The requested URL could not be matched by routing
.
I don’t know what the problem is, I hope you guys can help me. Here is the url to view the error on the site, and below follows my codes:
application.config.php
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
*/
return array(
// Retrieve the list of modules for this application.
'modules' => include __DIR__ . '/modules.config.php',
// This should be an array of paths in which modules reside.
// If a string key is provided, the listener will consider that a module
// namespace, the value of that key the specific path to that module's
// Module class.
'module_listener_options' => array(
'module_paths' => array(
'./module',
'./vendor'
),
// Using __DIR__ to ensure cross-platform compatibility. Some platforms --
// e.g., IBM i -- have problems with globs that are not qualified.
'config_glob_paths' => array('config/autoload/{,*.}{global,local}.php'),
'config_cache_key' => 'application.config.cache',
'config_cache_enabled' => true,
'module_map_cache_key' => 'application.module.cache',
'module_map_cache_enabled' => true,
'cache_dir' => 'data/cache/',
)
);
module.config.php
<?php
return array(
'service_manager' => array(
'factories' => array(
'Content_Analytics\\V1\\Rest\\Post\\PostResource' => 'Content_Analytics\\V1\\Rest\\Post\\PostResourceFactory',
),
'abstract_factories' => array(
0 => 'Zend\\Log\\LoggerAbstractServiceFactory',
),
),
'router' => array(
'routes' => array(
'content_analytics.rest.post' => array(
'type' => 'Segment',
'options' => array(
'route' => '/posts[/:post_id]',
'defaults' => array(
'controller' => 'Content_Analytics\\V1\\Rest\\Post\\Controller',
),
),
),
),
),
'zf-versioning' => array(
'uri' => array(
0 => 'content_analytics.rest.post',
),
),
'zf-rest' => array(
'Content_Analytics\\V1\\Rest\\Post\\Controller' => array(
'listener' => 'Content_Analytics\\V1\\Rest\\Post\\PostResource',
'route_name' => 'content_analytics.rest.post',
'route_identifier_name' => 'post_id',
'collection_name' => 'post',
'entity_http_methods' => array(
0 => 'GET',
1 => 'PATCH',
2 => 'PUT',
3 => 'DELETE',
),
'collection_http_methods' => array(
0 => 'GET',
1 => 'POST',
),
'collection_query_whitelist' => array(),
'page_size' => 25,
'page_size_param' => null,
'entity_class' => 'Content_Analytics\\V1\\Rest\\Post\\PostEntity',
'collection_class' => 'Content_Analytics\\V1\\Rest\\Post\\PostCollection',
'service_name' => 'post',
),
),
'zf-content-negotiation' => array(
'controllers' => array(
'Content_Analytics\\V1\\Rest\\Post\\Controller' => 'Json',
),
'accept_whitelist' => array(
'Content_Analytics\\V1\\Rest\\Post\\Controller' => array(
0 => 'application/vnd.content_analytics.v1+json',
1 => 'application/hal+json',
2 => 'application/json',
),
),
'content_type_whitelist' => array(
'Content_Analytics\\V1\\Rest\\Post\\Controller' => array(
0 => 'application/vnd.content_analytics.v1+json',
1 => 'application/json',
),
),
),
'zf-hal' => array(
'metadata_map' => array(
'Content_Analytics\\V1\\Rest\\Post\\PostEntity' => array(
'entity_identifier_name' => 'post_id',
'route_name' => 'content_analytics.rest.post',
'route_identifier_name' => 'post_id',
'hydrator' => 'Zend\\Stdlib\\Hydrator\\ArraySerializable',
),
'Content_Analytics\\V1\\Rest\\Post\\PostCollection' => array(
'entity_identifier_name' => 'post_id',
'route_name' => 'content_analytics.rest.post',
'route_identifier_name' => 'post_id',
'is_collection' => true,
),
),
),
'controllers' => array(
'factories' => array(
'Content_Analytics\\V1\\Rpc\\Post\\Controller' => 'Content_Analytics\\V1\\Rpc\\Post\\PostControllerFactory',
'Content_Analytics\\V1\\Rpc\\Posts\\Controller' => 'Content_Analytics\\V1\\Rpc\\Posts\\PostsControllerFactory',
),
),
'zf-rpc' => array(),
'zf-content-validation' => array(
'Content_Analytics\\V1\\Rest\\Post\\Controller' => array(
'input_filter' => 'Content_Analytics\\V1\\Rest\\Post\\Validator',
),
),
'input_filter_specs' => array(
'Content_Analytics\\V1\\Rest\\Post\\Validator' => array(
0 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'name' => 'key_api',
'description' => 'Google API developer key',
),
1 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'name' => 'post_id',
'description' => 'Post ID',
'continue_if_empty' => false,
),
2 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'name' => 'title',
'description' => 'Post Title',
),
3 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'name' => 'date_publishing',
'description' => 'Publication date of the post',
),
4 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'name' => 'url',
'description' => 'Post URL',
),
5 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'description' => 'Post Author',
'name' => 'author',
),
6 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'description' => 'Category Post',
'name' => 'category',
),
7 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'description' => 'Average session duration in post',
'name' => 'avg_sesionDuration',
),
8 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'description' => 'Views of post',
'name' => 'view',
),
9 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_Facebook',
'allow_empty' => true,
'description' => 'Number of visualizations in the Facebook',
),
10 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_Twitter',
'allow_empty' => true,
'description' => 'Number of visualizations in the Twitter',
),
11 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_Linkedin',
'allow_empty' => true,
'description' => 'Number of visualizations in the Linkedin',
),
12 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_Reddit',
'allow_empty' => true,
'description' => 'Number of visualizations in the Reddit',
),
13 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_StumbleUpon',
'allow_empty' => true,
'description' => 'Number of visualizations in the Stumble Upon',
),
14 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_GooglePlus',
'allow_empty' => true,
'description' => 'Number of visualizations in the Google Plus',
),
15 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_Pinterest',
'allow_empty' => true,
'description' => 'Number of visualizations in the Pinterest',
),
16 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_Flattr',
'allow_empty' => true,
'description' => 'Number of visualizations in the Flattr',
),
17 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'socialcount_XING',
'allow_empty' => true,
'description' => 'Number of visualizations in the Xing',
),
18 => array(
'required' => false,
'validators' => array(),
'filters' => array(),
'name' => 'update_date',
'description' => 'Update data post',
'allow_empty' => true,
),
19 => array(
'required' => true,
'validators' => array(),
'filters' => array(),
'name' => 'total_social_count',
'description' => 'Total social impact of post',
'allow_empty' => false,
),
),
),
);
php module.
<?php
namespace Content_Analytics;
use ZF\Apigility\Provider\ApigilityProviderInterface;
use Content_Analytics\V1\Rest\Post\PostEntity;
use Content_Analytics\V1\Rest\Post\PostMapper;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\ResultSet\ResultSet;
class Module implements ApigilityProviderInterface
{
public function getConfig()
{
return include __DIR__ . '/../../config/module.config.php';
}
public function getServiceConfig()
{
return array(
'factories' => array(
'contentanalyticsTableGateway' => function ($sm) {
$dbAdapter = $sm->get('db');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new PostEntity());
return new TableGateway('ca_blog_post', $dbAdapter, null, $resultSetPrototype);
},
'Content_Analytics\V1\Rest\Post\PostMapper' => function ($sm)
{
$tableGateway = $sm->get('contentanalyticsTableGateway');
return new PostMapper($tableGateway);
}
),
);
}
public function getAutoloaderConfig()
{
return array(
'ZF\Apigility\Autoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__,
),
),
);
}
}