optional. this is function php for change exist layer style in geoserver v2.3.0.
I solved it by folowing function notice that $params it have to put "<enabled>true</enabled>
" for enable layer after chang style in geoserver.
function change_layer_style($url_layer,$style_name) {
$params = '<layer><defaultStyle><name>'.$style_name.'</name></defaultStyle><enabled>true</enabled></layer>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url_layer);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_USERPWD,"user:password"); //geoserver.
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Receive server response ...
$response = curl_exec($ch);
curl_close ($ch);
return $response;
}
//--> how to use.
//--> 1. config your geoserver url.
$your_workspace = "xxx";"workspace_name";
$your_layer_name = = "bbb";"layer_name";
$url_layer = "http://xxxx.co.uk:8080/geoserver/rest/layers/".$your_workspace.":".$your_layer_name;
$style_name ="your_exist_style_name";
//--> call above function.
change_layer_style($url_layer,$style_name);